bunch of fixes
This commit is contained in:
+97
-26
@@ -22,6 +22,8 @@ vim.opt.hlsearch = false
|
|||||||
vim.opt.wrap = true
|
vim.opt.wrap = true
|
||||||
vim.opt.showmatch = true
|
vim.opt.showmatch = true
|
||||||
|
|
||||||
|
vim.g.python3_host_prog = '/home/frosty/.dotfiles/nvim/env/bin/python'
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('W', 'write', {})
|
vim.api.nvim_create_user_command('W', 'write', {})
|
||||||
|
|
||||||
vim.opt.foldmethod = "expr"
|
vim.opt.foldmethod = "expr"
|
||||||
@@ -46,15 +48,26 @@ function imap(shortcut, command)
|
|||||||
map('i', shortcut, command)
|
map('i', shortcut, command)
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.exists("g:neovide") then
|
|
||||||
vim.g.neovide_refresh_rate = 140
|
|
||||||
vim.opt.guifont = "Iosevka Nerd Font:h12"
|
vim.opt.guifont = "Iosevka Nerd Font:h12"
|
||||||
|
if vim.g.neovide then
|
||||||
|
vim.g.neovide_refresh_rate = 140
|
||||||
-- change to whatever font you prefer
|
-- change to whatever font you prefer
|
||||||
-- can check font with fc-cache on linux
|
-- can check font with fc-cache on linux
|
||||||
vim.g.neovide_hide_mouse_when_typing = true
|
vim.g.neovide_hide_mouse_when_typing = true
|
||||||
vim.g.neovide_refresh_rate_idle = 140
|
vim.g.neovide_refresh_rate_idle = 140
|
||||||
vim.g.neovide_scale_factor = 1.0
|
vim.g.neovide_scale_factor = 1.0
|
||||||
|
-- zoom with CTRL - and CTRL +
|
||||||
|
local change_scale_factor = function(delta)
|
||||||
|
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * delta
|
||||||
end
|
end
|
||||||
|
vim.keymap.set("n", "<C-=>", function()
|
||||||
|
change_scale_factor(1.25)
|
||||||
|
end)
|
||||||
|
vim.keymap.set("n", "<C-->", function()
|
||||||
|
change_scale_factor(1 / 1.25)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- <leader> is leader key; default is \
|
-- <leader> is leader key; default is \
|
||||||
nmap("<leader>v", "<cmd>NvimTreeToggle<cr>")
|
nmap("<leader>v", "<cmd>NvimTreeToggle<cr>")
|
||||||
@@ -72,8 +85,10 @@ nmap("<leader>t", "<cmd>FloatermToggle<cr>")
|
|||||||
map("t", "<leader>t", "<cmd>FloatermToggle<cr>")
|
map("t", "<leader>t", "<cmd>FloatermToggle<cr>")
|
||||||
|
|
||||||
-- lsp on_attach mappings
|
-- lsp on_attach mappings
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
|
if (not bufnr) then
|
||||||
|
return
|
||||||
|
end
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
@@ -94,13 +109,15 @@ local on_attach = function(client, bufnr)
|
|||||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
|
vim.keymap.set('n', '<space>f', '<cmd>lua vim.lsp.buf.format({ async = true })<CR>', bufopts)
|
||||||
|
|
||||||
require "coq".lsp_ensure_capabilities {}
|
require "coq".lsp_ensure_capabilities {}
|
||||||
require 'illuminate'.on_attach(client)
|
require 'illuminate'.on_attach(client)
|
||||||
|
require 'lsp-format'.on_attach(client)
|
||||||
|
|
||||||
-- format on save
|
-- format on save does not work for python for some reason
|
||||||
if client.supports_method("textDocument/formatting") then
|
--[[if client.supports_method("textDocument/formatting") then
|
||||||
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = augroup,
|
group = augroup,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
@@ -108,7 +125,8 @@ local on_attach = function(client, bufnr)
|
|||||||
vim.lsp.buf.format({ bufnr = bufnr })
|
vim.lsp.buf.format({ bufnr = bufnr })
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end ]]
|
||||||
|
--
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lsp config setup
|
-- lsp config setup
|
||||||
@@ -117,8 +135,9 @@ lsp.hls.setup { on_attach = on_attach } -- haskell language server
|
|||||||
lsp.ccls.setup { on_attach = on_attach }
|
lsp.ccls.setup { on_attach = on_attach }
|
||||||
lsp.pyright.setup { on_attach = on_attach }
|
lsp.pyright.setup { on_attach = on_attach }
|
||||||
lsp.tsserver.setup { on_attach = on_attach }
|
lsp.tsserver.setup { on_attach = on_attach }
|
||||||
|
lsp.marksman.setup { on_attach = on_attach }
|
||||||
lsp.rust_analyzer.setup { on_attach = on_attach }
|
lsp.rust_analyzer.setup { on_attach = on_attach }
|
||||||
lsp.sumneko_lua.setup { on_attach = on_attach,
|
lsp.lua_ls.setup { on_attach = on_attach,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
@@ -129,6 +148,12 @@ lsp.sumneko_lua.setup { on_attach = on_attach,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vim.cmd("colorscheme carbonfox")
|
vim.cmd("colorscheme carbonfox")
|
||||||
|
-- kill eslint_d on exit
|
||||||
|
local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {})
|
||||||
|
vim.api.nvim_create_autocmd("VimLeave", {
|
||||||
|
group = on_leave_group,
|
||||||
|
command = "silent !killall -q eslint_d",
|
||||||
|
})
|
||||||
|
|
||||||
-- packer boilerplate
|
-- packer boilerplate
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
@@ -141,6 +166,20 @@ end
|
|||||||
return require('packer').startup(function(use)
|
return require('packer').startup(function(use)
|
||||||
use 'wbthomason/packer.nvim'
|
use 'wbthomason/packer.nvim'
|
||||||
use 'nvim-lua/plenary.nvim'
|
use 'nvim-lua/plenary.nvim'
|
||||||
|
use { "lukas-reineke/lsp-format.nvim",
|
||||||
|
config = function()
|
||||||
|
require("lsp-format").setup {
|
||||||
|
python = {
|
||||||
|
sync = true,
|
||||||
|
force = true,
|
||||||
|
exclude = { "pyright" },
|
||||||
|
},
|
||||||
|
javascript = {
|
||||||
|
exclude = { "tsserver" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
use 'neovim/nvim-lspconfig'
|
use 'neovim/nvim-lspconfig'
|
||||||
use {
|
use {
|
||||||
'ms-jpq/coq_nvim',
|
'ms-jpq/coq_nvim',
|
||||||
@@ -153,7 +192,8 @@ return require('packer').startup(function(use)
|
|||||||
use {
|
use {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
run = ':TSUpdate',
|
run = ':TSUpdate',
|
||||||
config = function() require('nvim-treesitter.configs').setup {
|
config = function()
|
||||||
|
require('nvim-treesitter.configs').setup {
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true
|
enable = true
|
||||||
},
|
},
|
||||||
@@ -166,26 +206,54 @@ return require('packer').startup(function(use)
|
|||||||
},
|
},
|
||||||
config = function() require('nvim-tree').setup {} end
|
config = function() require('nvim-tree').setup {} end
|
||||||
}
|
}
|
||||||
|
--use { 'jose-elias-alvarez/typescript.nvim',
|
||||||
|
-- config = function() require("typescript")
|
||||||
use {
|
use {
|
||||||
'jose-elias-alvarez/null-ls.nvim',
|
'jose-elias-alvarez/null-ls.nvim',
|
||||||
config = function() require("null-ls").setup {
|
config = function()
|
||||||
sources = {
|
local null_ls = require("null-ls")
|
||||||
require("null-ls").builtins.formatting.eslint_d,
|
local lsp_conf = require("lspconfig")
|
||||||
require("null-ls").builtins.diagnostics.eslint_d,
|
|
||||||
require("null-ls").builtins.code_actions.eslint_d,
|
-- util.root_pattern returns a function
|
||||||
require("null-ls").builtins.diagnostics.flake8,
|
local find_pyproject = lsp_conf.util.root_pattern('pyproject.toml')
|
||||||
require("null-ls").builtins.formatting.black.with { extra_args = { "--fast" } },
|
local find_flake8 = lsp_conf.util.root_pattern('.flake8')
|
||||||
require("null-ls").builtins.formatting.isort,
|
|
||||||
require("null-ls").builtins.code_actions.gitsigns
|
local isort = null_ls.builtins.formatting.isort.with({
|
||||||
}
|
cwd = function(params)
|
||||||
|
return find_pyproject(params.root) or params.root
|
||||||
|
end
|
||||||
|
})
|
||||||
|
local black = null_ls.builtins.formatting.black.with({
|
||||||
|
extra_args = { "--config", "pyproject.toml" },
|
||||||
|
cwd = function(params)
|
||||||
|
return find_pyproject(params.root) or params.root
|
||||||
|
end
|
||||||
|
})
|
||||||
|
local flake8 = null_ls.builtins.diagnostics.flake8.with({
|
||||||
|
cwd = function(params)
|
||||||
|
return find_flake8(params.root) or params.root
|
||||||
|
end
|
||||||
|
})
|
||||||
|
local eslint_d_format = null_ls.builtins.formatting.eslint_d
|
||||||
|
local eslint_d_diag = null_ls.builtins.diagnostics.eslint_d
|
||||||
|
local eslint_d_code = null_ls.builtins.code_actions.eslint_d
|
||||||
|
local gitsigns = null_ls.builtins.code_actions.gitsigns
|
||||||
|
|
||||||
|
null_ls.setup {
|
||||||
|
debug = true,
|
||||||
|
on_attach = on_attach,
|
||||||
|
log_level = "debug"
|
||||||
}
|
}
|
||||||
|
null_ls.register({ isort, black, flake8, gitsigns })
|
||||||
|
null_ls.register({ name = "eslint_d", sources = { eslint_d_code, eslint_d_diag, eslint_d_format } })
|
||||||
end,
|
end,
|
||||||
requires = { "nvim-lua/plenary.nvim" },
|
requires = { "nvim-lua/plenary.nvim" },
|
||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
'folke/trouble.nvim',
|
'folke/trouble.nvim',
|
||||||
config = function() require("trouble").setup {
|
config = function()
|
||||||
nmap("<leader>xx", "<cmd>TroubleToggle<cr>");
|
require("trouble").setup {
|
||||||
|
nmap("<leader>xx", "<cmd>TroubleToggle<cr>"),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -193,7 +261,8 @@ return require('packer').startup(function(use)
|
|||||||
'akinsho/bufferline.nvim',
|
'akinsho/bufferline.nvim',
|
||||||
tag = "v2.*",
|
tag = "v2.*",
|
||||||
requires = 'kyazdani42/nvim-web-devicons',
|
requires = 'kyazdani42/nvim-web-devicons',
|
||||||
config = function() require("bufferline").setup {
|
config = function()
|
||||||
|
require("bufferline").setup {
|
||||||
options = {
|
options = {
|
||||||
diagnostics = "nvim_lsp",
|
diagnostics = "nvim_lsp",
|
||||||
}
|
}
|
||||||
@@ -201,7 +270,8 @@ return require('packer').startup(function(use)
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
use { "EdenEast/nightfox.nvim",
|
use { "EdenEast/nightfox.nvim",
|
||||||
config = function() require("nightfox").setup {}
|
config = function()
|
||||||
|
require("nightfox").setup {}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
@@ -242,9 +312,10 @@ return require('packer').startup(function(use)
|
|||||||
run = ':call doge#install()'
|
run = ':call doge#install()'
|
||||||
}
|
}
|
||||||
use { 'norcalli/nvim-colorizer.lua',
|
use { 'norcalli/nvim-colorizer.lua',
|
||||||
config = function() require('colorizer').setup {
|
config = function()
|
||||||
'css';
|
require('colorizer').setup {
|
||||||
'javascript';
|
'css',
|
||||||
|
'javascript',
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user