From 1fa7dd0709e3372dfa9d547a23ea441fdaf32630 Mon Sep 17 00:00:00 2001 From: Mora Unie Youer Date: Thu, 6 Mar 2025 20:54:40 +0300 Subject: feat: finally working LSP --- flake.nix | 6 +++--- lsp/lua-language-server.lua | 18 +++++++++++++++++ lua/config/init.lua | 3 +++ lua/config/lsp.lua | 1 + lua/config/plugins/completion.lua | 41 ++++++++++++++++++++++++++++++++++++++- lua/config/plugins/init.lua | 1 - lua/config/plugins/lsp.lua | 1 - 7 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 lsp/lua-language-server.lua create mode 100644 lua/config/lsp.lua delete mode 100644 lua/config/plugins/lsp.lua diff --git a/flake.nix b/flake.nix index 79094c6..9d55717 100644 --- a/flake.nix +++ b/flake.nix @@ -101,8 +101,9 @@ # at RUN TIME for plugins. Will be available to PATH within neovim terminal # this includes LSPs lspsAndRuntimeDeps = { - general = with pkgs; [ - ]; + general = with pkgs; { + lua = [ lua-language-server ]; + }; }; # This is for plugins that will load at startup without using packadd: @@ -136,7 +137,6 @@ completion = [ blink-cmp ]; # NOTE: On NeoVim 0.11+ nvim-lspconfig is not required due to native API - # lsp = [ nvim-lspconfig mason-nvim mason-lspconfig-nvim ]; lsp = []; mini = [ mini-ai mini-align mini-move mini-pairs mini-surround ]; diff --git a/lsp/lua-language-server.lua b/lsp/lua-language-server.lua new file mode 100644 index 0000000..3f5f308 --- /dev/null +++ b/lsp/lua-language-server.lua @@ -0,0 +1,18 @@ +return { + cmd = { "lua-language-server" }, + root_markers = { ".luarc.json" }, + filetypes = { "lua" }, + + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + formatters = { ignoreComments = true }, + signatureHelp = { enabled = true }, + diagnostics = { + globals = { "nixCats", "vim" }, + disable = { "missing-fields" }, + }, + telemetry = { enabled = false }, + }, + }, +} diff --git a/lua/config/init.lua b/lua/config/init.lua index 0c5bcb6..3517725 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -3,4 +3,7 @@ require("config.options") -- require("lze").register_handlers(require("nixCatsUtils.lzUtils").for_cat) require("lze").register_handlers(require("lzextras").lsp) +vim.lsp.set_log_level("debug") + require("config.plugins") +require("config.lsp") diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..c8444ef --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1 @@ +vim.lsp.enable("lua-language-server") diff --git a/lua/config/plugins/completion.lua b/lua/config/plugins/completion.lua index 7fd31c4..5b60993 100644 --- a/lua/config/plugins/completion.lua +++ b/lua/config/plugins/completion.lua @@ -3,7 +3,46 @@ return { "blink.cmp", event = "DeferredUIEnter", after = function(_) - require("blink.cmp").setup({}) + require("blink.cmp").setup({ + appearance = { + use_nvim_cmp_as_default = false, + nerd_font_variant = "mono", + }, + + completion = { + documentation = { + auto_show = true, + auto_show_delay_ms = 500, + }, + + ghost_text = { enabled = true }, + }, + + sources = { default = { "lsp", "path", "snippets", "buffer" } }, + + keymap = { + [""] = { "show", "show_documentation", "hide_documentation" }, + [""] = { "hide", "fallback" }, + [""] = { "accept", "fallback" }, + + [""] = { "snippet_forward", "fallback" }, + [""] = { "snippet_backward", "fallback" }, + + [""] = { "select_prev", "fallback" }, + [""] = { "select_next", "fallback" }, + [""] = { "select_prev", "fallback_to_mappings" }, + [""] = { "select_next", "fallback_to_mappings" }, + + [""] = { "scroll_documentation_up", "fallback" }, + [""] = { "scroll_documentation_down", "fallback" }, + }, + }) + + -- NOTE: this is broken due to something + -- local client_capabilities = vim.lsp.protocol.make_client_capabilities() + -- local blink_capabilities = require("blink.cmp").get_lsp_capabilities() + -- local capabilities = vim.tbl_deep_extend('force', client_capabilities, blink_capabilities) + -- vim.lsp.config("*", { capabilities = capabilities }) end, } } diff --git a/lua/config/plugins/init.lua b/lua/config/plugins/init.lua index a93419f..a1492e7 100644 --- a/lua/config/plugins/init.lua +++ b/lua/config/plugins/init.lua @@ -29,6 +29,5 @@ require("lze").load({ { import = "config.plugins.treesitter" }, { import = "config.plugins.mini" }, { import = "config.plugins.completion" }, - { import = "config.plugins.lsp" }, { import = "config.plugins.extra" }, }) diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua deleted file mode 100644 index a564707..0000000 --- a/lua/config/plugins/lsp.lua +++ /dev/null @@ -1 +0,0 @@ -return {} -- cgit v1.2.3-70-g09d2