neovim-config/lua/plugins/lsp.lua

83 lines
2.1 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,
})
require('lspconfig')['tsserver'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
require('lspconfig')['jsonls'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
require('lspconfig')['eslint'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
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'] = {}
-- }
-- })
require('lspconfig')['sumneko_lua'].setup({
on_attach = on_attach,
flags = lsp_flags,
settings = {
Lua = {
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,
})
require('lspconfig')['sqls'].setup({
on_attach = on_attach,
flags = lsp_flags,
})
require('lspconfig')['taplo'].setup({
on_attach = on_attach,
flags = lsp_flags,
})