Uses arch aur-packaged installation of sumneko_lua, and invokes it for any lua file. Takes care of some additional configuration to enable easier programming for neovim itself.
60 lines
2.6 KiB
Lua
60 lines
2.6 KiB
Lua
local on_attach = function(client, bufnr)
|
|
-- Keybindings for LSPs
|
|
-- Note these are in on_attach so that they don't override bindings in a non-LSP setting
|
|
vim.fn.nvim_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>",
|
|
{noremap = true, silent = true})
|
|
vim.fn.nvim_set_keymap("n", "gD",
|
|
"<cmd>lua vim.lsp.buf.implementation()<CR>",
|
|
{noremap = true, silent = true})
|
|
vim.fn.nvim_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>",
|
|
{noremap = true, silent = true})
|
|
vim.fn.nvim_set_keymap("n", "gK",
|
|
"<cmd>lua vim.lsp.buf.signature_help()<CR>",
|
|
{noremap = true, silent = true})
|
|
vim.fn.nvim_set_keymap("n", "1gD",
|
|
"<cmd>lua vim.lsp.buf.type_definition()<CR>",
|
|
{noremap = true, silent = true})
|
|
vim.fn.nvim_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>",
|
|
{noremap = true, silent = true})
|
|
vim.fn.nvim_set_keymap("n", "g0",
|
|
"<cmd>lua vim.lsp.buf.document_symbol()<CR>",
|
|
{noremap = true, silent = true})
|
|
vim.fn.nvim_set_keymap("n", "gW",
|
|
"<cmd>lua vim.lsp.buf.workspace_symbol()<CR>",
|
|
{noremap = true, silent = true})
|
|
end
|
|
|
|
require'lspconfig'.pyls.setup {on_attach = on_attach}
|
|
require'lspconfig'.vimls.setup {on_attach = on_attach}
|
|
require'lspconfig'.bashls.setup {on_attach = on_attach}
|
|
require'lspconfig'.gopls.setup {on_attach = on_attach}
|
|
require'lspconfig'.texlab.setup {on_attach = on_attach}
|
|
|
|
-- requires the lua-language-server package to be installed
|
|
-- The arch package defaults to the following directory
|
|
local sumneko_root_path = "/usr/share/lua-language-server"
|
|
require'lspconfig'.sumneko_lua.setup {
|
|
cmd = { "lua-language-server", "-E", sumneko_root_path .. "/main.lua"};
|
|
settings = {
|
|
Lua = {
|
|
runtime = {
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
version = 'LuaJIT',
|
|
-- Setup your lua path
|
|
path = vim.split(package.path, ';'),
|
|
},
|
|
diagnostics = {
|
|
-- Get the language server to recognize the `vim` global
|
|
globals = {'vim'},
|
|
},
|
|
workspace = {
|
|
-- Make the server aware of Neovim runtime files
|
|
library = {
|
|
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
|
|
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
on_attach = on_attach,
|
|
}
|