all repos — dotfiles @ 31f541d8c62a1fe784132f9009838179b4c29f2a

linux dotfiles

nvim: update init.lua and add lua lsp
Prithu Goswami pg@prithu.dev
Tue, 12 Mar 2024 08:36:02 +0530
commit

31f541d8c62a1fe784132f9009838179b4c29f2a

parent

e781918e358e8342fd5f63abeedadc9b0cfe117d

2 files changed, 42 insertions(+), 0 deletions(-)

jump to
M config/nvim/init.luaconfig/nvim/init.lua

@@ -26,6 +26,9 @@

require("nvim-tree").setup({ on_attach = nvim_tree_on_attach, sort_by = "case_sensitive", + update_focused_file = { + enable = true, + }, view = { centralize_selection = true, signcolumn = "auto",

@@ -170,4 +173,5 @@ autocmd FileType html,javascript,lua,typescript,yaml setlocal ts=2 sts=2 sw=2

autocmd FileType hcl setlocal ts=2 sts=2 sw=2 autocmd BufRead *jsx setlocal sw=2 autocmd BufRead *tsx setlocal sw=2 + autocmd FileType markdown setlocal spell ]])
M config/nvim/lua/lsp/init.luaconfig/nvim/lua/lsp/init.lua

@@ -110,6 +110,43 @@ capabilities = capabilities,

on_attach = on_attach, } +lspconfig.ccls.setup{ + capabilities = capabilities, + on_attach = on_attach, +} + +lspconfig.lua_ls.setup { + capabilities = capabilities, + on_attach = on_attach, + on_init = function(client) + local path = client.workspace_folders[1].name + if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then + client.config.settings = 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 + -- "${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) + } + } + }) + + client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) + end + return true + end +} -- lspconfig.terraformls.setup{ -- capabilities = capabilities,

@@ -140,3 +177,4 @@ end,

}), }, }) +