nvim: upgrade blink-cmp. lsp config for web stuff.

This commit is contained in:
Daniel Lundin 2024-12-02 09:42:24 +01:00
parent 7a4712c057
commit 37ddc91613
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
4 changed files with 106 additions and 56 deletions

View file

@ -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 @@
["<PageDown>"] = { "scroll_documentation_down" },
["<PageUp>"] = { "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";

View file

@ -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 <nixpkgs> { }" },
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 <nixpkgs> { }" },
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

View file

@ -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";
}

View file

@ -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 { };