neovim-config/lua/plugins/lsp.lua

95 lines
2.4 KiB
Lua
Raw Normal View History

2022-10-06 04:44:41 +00:00
local on_attach = require('plugins.lsp.on_attach')
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
local lsp_flags = {
-- This is the default in Nvim 0.7+
debounce_text_changes = 150,
}
require('lspconfig')['pyright'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
2023-12-01 20:26:00 +00:00
-- Setup by typescript.nvim automatically
-- require('lspconfig')['tsserver'].setup({
-- on_attach = on_attach,
-- flags = lsp_flags,
-- })
2022-10-06 04:44:41 +00:00
require('lspconfig')['jsonls'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
require('lspconfig')['eslint'].setup({
on_attach = on_attach,
flags = lsp_flags,
2023-12-01 20:26:00 +00:00
root_dir = require('lspconfig').util.find_git_ancestor,
2022-10-06 04:44:41 +00:00
})
require('lspconfig')['html'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
require('lspconfig')['cssls'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
-- Setup by rust-tools automatically
-- require('lspconfig')['rust_analyzer'].setup({
-- on_attach = on_attach,
-- flags = lsp_flags,
-- -- Server-specific settings...
-- settings = {
-- ['rust-analyzer'] = {}
-- }
-- })
2023-12-01 20:26:00 +00:00
require('lspconfig')['lua_ls'].setup({
2022-10-06 04:44:41 +00:00
on_attach = on_attach,
flags = lsp_flags,
settings = {
Lua = {
completion = {
callSnippet = "Replace"
},
2022-10-06 04:44:41 +00:00
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { 'vim' },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file('', true),
},
},
},
})
require('lspconfig')['bashls'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
require('lspconfig')['marksman'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
2023-12-01 20:26:01 +00:00
require('lspconfig')['sqlls'].setup({
2023-12-01 20:26:00 +00:00
on_attach = function(client, bufn)
2023-12-01 20:26:00 +00:00
on_attach(client, bufn)
2023-12-01 20:26:01 +00:00
require('sqlls').on_attach(client, bufn)
2023-12-01 20:26:00 +00:00
end,
2022-10-06 04:44:41 +00:00
flags = lsp_flags,
})
require('lspconfig')['taplo'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
2023-12-01 20:26:00 +00:00
require('lspconfig')['zls'].setup({
on_attach = on_attach,
flags = lsp_flags,
})