Add lsp for .lua
This commit is contained in:
parent
405080b22d
commit
e0e927edb1
@ -51,6 +51,7 @@
|
||||
nodePackages.typescript-language-server
|
||||
nil
|
||||
yaml-language-server
|
||||
lua-language-server
|
||||
];
|
||||
home.sessionVariables.EDITOR = "nvim";
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
-- LSP stuff
|
||||
local lsp_zero = require('lsp-zero')
|
||||
|
||||
|
||||
lsp_zero.on_attach(function(client, bufnr)
|
||||
lsp_zero.default_keymaps({ buffer = bufnr })
|
||||
end)
|
||||
@ -15,6 +16,7 @@ lsp_zero.format_on_save({
|
||||
servers = {
|
||||
['gopls'] = { 'go' },
|
||||
['nil_ls'] = { 'nix' },
|
||||
['lua_ls'] = { 'lua' },
|
||||
},
|
||||
})
|
||||
|
||||
@ -42,6 +44,46 @@ lspconfig.nil_ls.setup({
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig.lua_ls.setup({
|
||||
on_init = function(client)
|
||||
local path = client.workspace_folders[1].name
|
||||
if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
||||
return
|
||||
end
|
||||
|
||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using
|
||||
-- (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
-- Depending on the usage, you might want to add additional paths here.
|
||||
-- "${3rd}/luv/library"
|
||||
-- "${3rd}/busted/library",
|
||||
}
|
||||
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
|
||||
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||
}
|
||||
})
|
||||
end,
|
||||
settings = {
|
||||
Lua = {
|
||||
format = {
|
||||
enable = true,
|
||||
defaultConfig = {
|
||||
indent_style = "space",
|
||||
indent_size = "2",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- Telescope
|
||||
require('telescope').setup({
|
||||
|
Loading…
Reference in New Issue
Block a user