diff --git a/home/common/nvim/default.nix b/home/common/nvim/default.nix index eade3f0..ce2f78b 100644 --- a/home/common/nvim/default.nix +++ b/home/common/nvim/default.nix @@ -42,6 +42,7 @@ shellcheck shfmt stylua + superhtml vscode-langservers-extracted ]; @@ -59,7 +60,7 @@ } { - plugin = blink-cmp; + plugin = pkgs.blink-cmp; type = "lua"; config = '' require'blink-cmp'.setup({ @@ -68,27 +69,31 @@ [""] = { "scroll_documentation_down" }, [""] = { "scroll_documentation_up" }, }, - trigger = { - completion = { - show_in_snippet = true, - }, - signature_help = { - enabled = true, - }, - }, - windows = { - autocomplete = { - border = 'none', - selection = 'preselect', + completion = { + accept = { + auto_brackets = { + enabled = true, + }, }, + documentation = { - border = 'rounded', - auto_show = false, + auto_show = true, auto_show_delay_ms = 800, + window = { + border = 'rounded', + }, + ghost_text = { + enabled = true, + }, }, - signature_help = { - border = 'rounded', + + signature = { + enabled = true, + window = { + border = 'rounded', + }, }, + }, }) ''; @@ -100,8 +105,8 @@ src = pkgs.fetchFromGitHub { owner = "saghen"; repo = "blink.compat"; - rev = "cd2d3a040b76ad0eeab9a3bba48bc4c2b9d703bf"; # v1.0.2 - hash = "sha256-4uoehv/qe74IivgXc69ekYLod3Zo+oPUvXJHtt4wc2U="; + rev = "78f3f7187ff4a1444e952548c556d936da8f72fc"; # v2.1.2 + hash = "sha256-aqHDwrzPOyOw9UbJlQX10/cVQwNHg4v6i9jSm+pNKZc="; }; }; type = "lua"; diff --git a/home/common/nvim/lsp.lua b/home/common/nvim/lsp.lua index 7a8d0c5..0123089 100644 --- a/home/common/nvim/lsp.lua +++ b/home/common/nvim/lsp.lua @@ -1,44 +1,43 @@ -local configs = require('lspconfig.configs') local lspconfig = require("lspconfig") -local capabilities = vim.lsp.protocol.make_client_capabilities() local servers = { - 'gopls', - 'ts_ls', -} + cssls = {}, + gopls = {}, + html = {}, + jsonls = {}, + superhtml = {}, + ts_ls = {}, -for _, ls in ipairs(servers) do - lspconfig[ls].setup { - capabilities = capabilities, - } -end - -lspconfig.nixd.setup({ - capabilities = capabilities, - cmd = { "nixd" }, - settings = { - nixd = { - nixpkgs = { expr = "import { }" }, - formatting = { command = { "nixfmt" } }, - options = {}, - }, - }, -}) - -lspconfig.lua_ls.setup({ - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { globals = { "vim", "hs" } }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, + lua_ls = { + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { globals = { "vim", "hs" } }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, + }, }, }, }, }, -}) + + nixd = { + cmd = { "nixd" }, + settings = { + nixd = { + nixpkgs = { expr = "import { }" }, + formatting = { command = { "nixfmt" } }, + options = {}, + }, + }, + }, +} + +for server, config in pairs(servers) do + config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities) + lspconfig[server].setup(config) +end diff --git a/pkgs/blink-cmp/default.nix b/pkgs/blink-cmp/default.nix new file mode 100644 index 0000000..e9307e4 --- /dev/null +++ b/pkgs/blink-cmp/default.nix @@ -0,0 +1,45 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + stdenv, + vimUtils, +}: +let + version = "0.7.3"; + src = fetchFromGitHub { + owner = "Saghen"; + repo = "blink.cmp"; + rev = "refs/tags/v${version}"; + hash = "sha256-nxiODLKgGeXzN5sqkLWU0PcsuSSB1scSzTC5qyCxLCI="; + }; + libExt = if stdenv.hostPlatform.isDarwin then "dylib" else "so"; + blink-fuzzy-lib = rustPlatform.buildRustPackage { + inherit version src; + pname = "blink-fuzzy-lib"; + env = { + # TODO: remove this if plugin stops using nightly rust + RUSTC_BOOTSTRAP = true; + }; + useFetchCargoVendor = true; + cargoHash = "sha256-XXI2jEoD6XbFNk3O8B6+aLzl1ZcJq1VinQXb+AOw8Rw="; + }; +in +vimUtils.buildVimPlugin { + pname = "blink-cmp"; + inherit version src; + preInstall = '' + mkdir -p target/release + ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt} + ''; + meta = { + description = "Performant, batteries-included completion plugin for Neovim"; + homepage = "https://github.com/saghen/blink.cmp"; + maintainers = with lib.maintainers; [ + balssh + redxtech + ]; + }; + doInstallCheck = true; + nvimRequireCheck = "blink-cmp"; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index ab3485b..1ee0f62 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,4 +1,5 @@ pkgs: { + blink-cmp = pkgs.callPackage ./blink-cmp { }; gnome-ssh-askpass4 = pkgs.callPackage ./gnome-ssh-askpass4 { }; jujutsu-openssh = pkgs.callPackage ./jujutsu-openssh { }; lazyjj = pkgs.callPackage ./lazyjj { };