update neovim config to use lazy, fix some issues with screens in general
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
local augroup = vim.api.nvim_create_augroup("Lspformatting", {})
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
if (not bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
require 'illuminate'.on_attach(client)
|
||||
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, 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', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>f', '<cmd>lua vim.lsp.buf.format({ async = true })<CR>', bufopts)
|
||||
|
||||
-- format on save does not work for python for some reason
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({
|
||||
async = false,
|
||||
bufnr = bufnr,
|
||||
})
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
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",
|
||||
})
|
||||
|
||||
|
||||
return { {
|
||||
'neovim/nvim-lspconfig',
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
'hrsh7th/nvim-cmp',
|
||||
'RRethy/vim-illuminate',
|
||||
'j-hui/fidget.nvim',
|
||||
},
|
||||
config = function()
|
||||
local lsp = require("lspconfig")
|
||||
local lspconfig_defaults = lsp.util.default_config
|
||||
lspconfig_defaults.capabilities = vim.tbl_deep_extend(
|
||||
'force',
|
||||
lspconfig_defaults.capabilities,
|
||||
require('cmp_nvim_lsp').default_capabilities()
|
||||
)
|
||||
--local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
lsp.lua_ls.setup({
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'vim' }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
lsp.clangd.setup { on_attach = on_attach }
|
||||
lsp.ts_ls.setup { on_attach = on_attach } -- typescript
|
||||
lsp.hls.setup { on_attach = on_attach } -- haskell
|
||||
lsp.pyright.setup { on_attach = on_attach,
|
||||
settings = {
|
||||
pyright = {
|
||||
disableOrganizeImports = true, -- Using Ruff
|
||||
},
|
||||
python = {
|
||||
analysis = {
|
||||
ignore = { '*' }, -- Using Ruff
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
lsp.ruff.setup { on_attach = on_attach }
|
||||
lsp.svelte.setup { on_attach = on_attach }
|
||||
lsp.marksman.setup { on_attach = on_attach }
|
||||
lsp.rust_analyzer.setup { on_attach = on_attach,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
checkOnSave = true,
|
||||
check = {
|
||||
enable = true,
|
||||
command = "clippy",
|
||||
features = "all"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lsp.tailwindcss.setup { on_attach = on_attach }
|
||||
|
||||
lsp.julials.setup {
|
||||
on_new_config = function(new_config, _)
|
||||
local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia")
|
||||
if lsp.util.path.is_file(julia) then
|
||||
vim.notify("running julials")
|
||||
new_config.cmd[1] = julia
|
||||
end
|
||||
end,
|
||||
on_attach = on_attach
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
'nvimtools/none-ls.nvim',
|
||||
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
local null_ls = require("null-ls")
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
--capabilities.offsetEncoding = { "utf-16" }
|
||||
|
||||
local eslint_format = require("none-ls.formatting.eslint_d").with({
|
||||
extra_filetypes = { "svelte" },
|
||||
})
|
||||
|
||||
local eslint_diag = require("none-ls.diagnostics.eslint_d").with({
|
||||
extra_filetypes = { "svelte" },
|
||||
})
|
||||
|
||||
local eslint_code_actions = require("none-ls.code_actions.eslint_d").with({
|
||||
extra_filetypes = { "svelte" },
|
||||
})
|
||||
|
||||
null_ls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
sources = {
|
||||
eslint_format,
|
||||
eslint_diag,
|
||||
eslint_code_actions,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.completion.luasnip,
|
||||
null_ls.builtins.completion.tags,
|
||||
}
|
||||
}
|
||||
end,
|
||||
dependencies = { "nvim-lua/plenary.nvim",
|
||||
"nvimtools/none-ls-extras.nvim",
|
||||
'hrsh7th/nvim-cmp',
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user