diff --git a/.emmyrc.json b/.emmyrc.json new file mode 100644 index 0000000..f379057 --- /dev/null +++ b/.emmyrc.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json", + "runtime": { + "version": "LuaJIT", + "requirePattern": [ + "lua/?.lua", + "lua/?/init.lua", + "?/lua/?.lua", + "?/lua/?/init.lua" + ] + }, + "workspace": { + "library": [ + "$VIMRUNTIME", + "$HOME/.local/share/nvim/lazy/luvit-meta", + "$HOME/.local/share/nvim/lazy/lazy.nvim" + ], + "ignoreGlobs": ["**/*_spec.lua"] + } +} diff --git a/lua/taken/plugins/lsp/lspconfig.lua b/lua/taken/plugins/lsp/lspconfig.lua index 1ae3a2b..ae35132 100644 --- a/lua/taken/plugins/lsp/lspconfig.lua +++ b/lua/taken/plugins/lsp/lspconfig.lua @@ -13,9 +13,8 @@ return { config = function() require("lspconfig") local tserrortranslator = require("ts-error-translator") - local util = require("lspconfig.util") local on_attach = require("taken.utils.on_attach") - local path = util.path + local get_python_path = require("taken.utils.lsp").get_python_path -- local cmp_nvim_lsp = require("cmp_nvim_lsp") -- local capabilities = cmp_nvim_lsp.default_capabilities() @@ -23,11 +22,26 @@ return { local blink = require("blink.cmp") local capabilities = blink.get_lsp_capabilities() - local signs = { Error = " ", Warn = " ", Hint = "ﴞ ", Info = " " } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) - end + vim.diagnostic.config({ + signs = { + [vim.diagnostic.severity.ERROR] = " ", + [vim.diagnostic.severity.WARN] = " ", + [vim.diagnostic.severity.HINT] = "ﴞ ", + [vim.diagnostic.severity.INFO] = " ", + }, + -- linehl = { + -- [vim.diagnostic.severity.ERROR] = "DiagnosticSignError", + -- [vim.diagnostic.severity.WARN] = "DiagnosticSignWarn", + -- [vim.diagnostic.severity.HINT] = "DiagnosticSignHint", + -- [vim.diagnostic.severity.INFO] = "DiagnosticSignInfo", + -- }, + -- numhl = { + -- [vim.diagnostic.severity.ERROR] = "DiagnosticSignError", + -- [vim.diagnostic.severity.WARN] = "DiagnosticSignWarn", + -- [vim.diagnostic.severity.HINT] = "DiagnosticSignHint", + -- [vim.diagnostic.severity.INFO] = "DiagnosticSignInfo", + -- }, + }) local defaultLsps = { "html", @@ -45,6 +59,11 @@ return { on_attach = on_attach, }) + -- vim.lsp.config("emmylua_ls", { + -- capabilities = capabilities, + -- on_attach = on_attach, + -- }) + -- lua vim.lsp.config("lua_ls", { capabilities = capabilities, @@ -70,23 +89,6 @@ return { }, }) - local function get_python_path(workspace) - -- Use activated virtualenv. - if vim.env.VIRTUAL_ENV then - return path.join(vim.env.VIRTUAL_ENV, "bin", "python") - end - - -- Find and use virtualenv in workspace directory. - for _, pattern in ipairs({ "*", ".*" }) do - local match = vim.fn.glob(path.join(workspace, pattern, "pyvenv.cfg")) - if match ~= "" then - return path.join(path.dirname(match), "bin", "python") - end - end - - return nil - end - -- python vim.lsp.config("pyright", { capabilities = capabilities, @@ -140,10 +142,13 @@ return { }) vim.lsp.enable(defaultLsps) - vim.lsp.enable("lua_ls") - vim.lsp.enable("pyright") - vim.lsp.enable("ts_ls") - vim.lsp.enable("powershell_es") + vim.lsp.enable({ + "lua_ls", + -- "emmylua_ls", + "pyright", + "ts_ls", + "powershell_es", + }) tserrortranslator.setup() end, diff --git a/lua/taken/plugins/lsp/mason.lua b/lua/taken/plugins/lsp/mason.lua index 25afeb1..833ad62 100644 --- a/lua/taken/plugins/lsp/mason.lua +++ b/lua/taken/plugins/lsp/mason.lua @@ -39,6 +39,7 @@ return { "tailwindcss", "marksman", "eslint", + "emmylua_ls", }, automatic_installation = true, }) diff --git a/lua/taken/utils/lsp.lua b/lua/taken/utils/lsp.lua new file mode 100644 index 0000000..8dcd7b6 --- /dev/null +++ b/lua/taken/utils/lsp.lua @@ -0,0 +1,23 @@ +local M = {} + +local util = require("lspconfig.util") +local path = util.path + +M.get_python_path = function(workspace) + -- Use activated virtualenv. + if vim.env.VIRTUAL_ENV then + return path.join(vim.env.VIRTUAL_ENV, "bin", "python") + end + + -- Find and use virtualenv in workspace directory. + for _, pattern in ipairs({ "*", ".*" }) do + local match = vim.fn.glob(path.join(workspace, pattern, "pyvenv.cfg")) + if match ~= "" then + return path.join(path.dirname(match), "bin", "python") + end + end + + return nil +end + +return M