From a15a5951b67d09f1c2fdadcb5ee8a9607aad53dd Mon Sep 17 00:00:00 2001 From: Olaf Alexander Date: Fri, 10 Jan 2025 16:14:01 -0600 Subject: [PATCH] fix(nvim): Rename LSP plugin file --- dot-config/nvim/lua/plugins/lsp.lua | 60 +++++++++++++++++++++++++++ dot-config/nvim/lua/plugins/mason.lua | 26 ------------ 2 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 dot-config/nvim/lua/plugins/lsp.lua delete mode 100644 dot-config/nvim/lua/plugins/mason.lua diff --git a/dot-config/nvim/lua/plugins/lsp.lua b/dot-config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..1692eb2 --- /dev/null +++ b/dot-config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,60 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end, + }, + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "ts_ls" }, + }) + end, + }, + { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({ + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then + return + end + 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 and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189) + -- library = vim.api.nvim_get_runtime_file("", true) + } + }) + end, + settings = { + Lua = {} + } + + }) + lspconfig.ts_ls.setup({}) + vim.keymap.set("n", "K", vim.lsp.buf.hover, {}) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, {}) + end, + }, +} diff --git a/dot-config/nvim/lua/plugins/mason.lua b/dot-config/nvim/lua/plugins/mason.lua deleted file mode 100644 index fa146cc..0000000 --- a/dot-config/nvim/lua/plugins/mason.lua +++ /dev/null @@ -1,26 +0,0 @@ -return { - { - "williamboman/mason.nvim", - config = function() - require("mason").setup() - end, - }, - { - "williamboman/mason-lspconfig.nvim", - config = function() - require("mason-lspconfig").setup({ - ensure_installed = { "lua_ls" }, - }) - end, - }, - { - "neovim/nvim-lspconfig", - config = function() - local lspconfig = require("lspconfig") - lspconfig.lua_ls.setup({}) - vim.keymap.set("n", "K", vim.lsp.buf.hover, {}) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) - vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, {}) - end, - }, -}