nvim: blink-cmp 0.5.1 + styling

This commit is contained in:
Daniel Lundin 2024-11-09 10:09:10 +01:00
parent 1eb8637840
commit b433ecef3c
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
7 changed files with 108 additions and 79 deletions

View file

@ -103,11 +103,11 @@
"zig": "zig"
},
"locked": {
"lastModified": 1730931741,
"narHash": "sha256-UMqGcC+14MCiTdyMrUrVX/4wJvOBXhCNdR/bt6mTank=",
"lastModified": 1731023348,
"narHash": "sha256-9k2ynQywm8AWi27C2o+/KAFpqV6PwZgaSyqhSqW8ZOs=",
"ref": "refs/heads/main",
"rev": "444cf3b402f658f33b76a05b9e43dfc2df89f892",
"revCount": 7904,
"rev": "75fe0b2dfb200dda2622b0fbc790e9451ffff236",
"revCount": 7916,
"type": "git",
"url": "ssh://git@github.com/ghostty-org/ghostty"
},
@ -232,11 +232,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1730914682,
"narHash": "sha256-UHFvVeJY64rA5HKoeKCLuJET224GEDGdj7/m1PuShgw=",
"lastModified": 1731111231,
"narHash": "sha256-8u8k3hnU5OxlXfhDLD3XEwAqv/M9Tb5USLCEPvXCPcM=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "59630b2edb91b71ac0a60b865aaa91cd39946577",
"rev": "702364e6ec794961483eba5220ca531917d03784",
"type": "github"
},
"original": {
@ -248,11 +248,11 @@
"neovim-src": {
"flake": false,
"locked": {
"lastModified": 1730893053,
"narHash": "sha256-ifiJfPkhyg/9I9aJSbtcHy3jRV4CLig7iF9ACQUycPU=",
"lastModified": 1731083384,
"narHash": "sha256-0uH8SSP6/eqCuDvUCV+s1ZwjLg6512Vj9dgKKO0iEmE=",
"owner": "neovim",
"repo": "neovim",
"rev": "f7e32fb6e626ab198bf401765236783890f3a0d6",
"rev": "ad3472e291694b6c589d8a664459b03962eaac95",
"type": "github"
},
"original": {
@ -263,11 +263,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1730831018,
"narHash": "sha256-2S0HwIFRxYp+afuoFORcZA9TjryAf512GmE0MTfEOPU=",
"lastModified": 1730958623,
"narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8c4dc69b9732f6bbe826b5fbb32184987520ff26",
"rev": "85f7e662eda4fa3a995556527c87b2524b691933",
"type": "github"
},
"original": {
@ -293,6 +293,22 @@
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1730958623,
"narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "85f7e662eda4fa3a995556527c87b2524b691933",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1730785428,
@ -316,7 +332,8 @@
"home-manager": "home-manager",
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable"
"nixpkgs-stable": "nixpkgs-stable",
"nixpkgs-unstable": "nixpkgs-unstable"
}
},
"systems": {

View file

@ -17,6 +17,7 @@
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";

View file

@ -46,23 +46,45 @@
];
plugins = with pkgs.vimPlugins; [
friendly-snippets
go-nvim
rustaceanvim
targets-vim
ts-comments-nvim
{
plugin = blink-cmp;
plugin = nvim-lspconfig;
type = "lua";
config = lib.fileContents ./lsp.lua;
}
{
plugin = pkgs.nixpkgs-unstable.vimPlugins.blink-cmp;
type = "lua";
config = ''
require'blink-cmp'.setup({
keymap = 'super-tab',
keymap = {
preset = 'enter',
["<PageDown>"] = { "scroll_documentation_down" },
["<PageUp>"] = { "scroll_documentation_up" },
},
trigger = {
completion = {
show_in_snippet = true,
},
signature_help = {
enabled = true,
},
},
windows = {
autocomplete = {
border = 'none',
selection = 'preselect',
},
documentation = {
border = 'rounded',
auto_show = false,
auto_show_delay_ms = 800,
},
signature_help = {
border = 'rounded',
@ -88,7 +110,7 @@
src = pkgs.fetchFromGitHub {
owner = "monkoose";
repo = "neocodeium";
rev = "4da81528468b33585c411f31eb390dce573ccb14"; # v1.8.0
rev = "4da81528468b33585c411f31eb390dce573ccb14"; # v1.8.0
hash = "sha256-1n9nNqBNwNDSzbAkm8eB4HZLNy5HmMg25jPwQAnW5OU=";
};
};
@ -141,12 +163,6 @@
type = "lua";
config = lib.fileContents ./mini.lua;
}
{
plugin = nvim-lspconfig;
type = "lua";
config = lib.fileContents ./lsp.lua;
}
];
};
}

View file

@ -156,17 +156,25 @@ local theme = {
InclineNormalNC = { bg = c.background },
WinSeparator = { bg = c.dialog_bg, fg = c.dialog_fg },
NormalFloat = { bg = c.dialog_bg, fg = c.dialog_fg },
NormalFloat = { bg = c.doc_bg, fg = c.doc_fg },
FloatBorder = { fg = c.doc_fg },
FloatTitle = { fg = c.doc_fg, bold = true },
Title = { fg = c.foreground, bold = true },
FloatBorder = { fg = c.dialog_fg },
FloatTitle = { fg = c.dialog_fg, bold = true },
MiniPickNormal = { link = "Normal" },
MiniPickBorder = { link = "MiniPickNormal" },
MiniPickBorderText = { link = "MiniPickBorder" },
MiniPickMatchCurrent = { bg = c.background, fg = c.foreground, reverse = true },
MiniStarterCurrent = { link = "MiniPickMatchCurrent" },
MiniClueNextKey = { bg = c.dialog_bg, fg = c.dialog_fg, bold = true },
MiniClueBorder = { link = "MiniPickNormal" },
MiniClueTitle = { bg = c.background, fg = c.foreground, bold = true },
MiniClueNextKey = { link = "MiniClueTitle" },
MiniClueDescGroup = { bg = c.background, fg = c.foreground, italic = true },
MiniClueSeparator = { link = "NormalFloat" },
MiniClueDescSingle = { bg = c.background, fg = c.foreground },
MiniClueSeparator = { link = "MiniClueBorder" },
MiniStarterCurrent = { link = "MiniPickMatchCurrent" },
BlinkCmpMenu = { bg = c.cmp_bg, fg = c.cmp_fg },
BlinkCmpMenuSelection = { bg = c.cmp_selected_bg, fg = c.cmp_selected_fg, reverse = false },

View file

@ -86,6 +86,7 @@ vim.fn.sign_define(
{ text = "", hl = "DiagnosticSignHint", texthl = "DiagnosticSignHint", culhl = "DiagnosticSignHintLine" }
)
-- Make <Tab> work for snippets
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.snippet.active({ direction = 1 }) then
@ -128,11 +129,20 @@ vim.keymap.set("n", "<Leader>wv", "<C-w>v", opts("Vertical split"))
vim.keymap.set('n', '<tab>', "<cmd>Pick buffers include_current=false<cr>", opts("Buffers"))
vim.keymap.set("n", "zz", "zt", { remap = true })
vim.keymap.set({ "n", "v" }, "<Leader>y", '"+y', opts("Yank to clipboard"))
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts("Declaration"))
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts("Definition"))
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts("Implementation"))
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts("Buffer References"))
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, opts("Type Definition"))
vim.keymap.set({"n", "i"}, "<M-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
vim.keymap.set({ "n", "i" }, "<M-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
vim.keymap.set({ "n", "v" }, "<Leader>aa", vim.lsp.buf.code_action, opts("Code Action"))
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover {
border = 'rounded',
max_height = 24,
max_width = 80,
offset_x = 2,
}
end, {})

View file

@ -1,26 +1,6 @@
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = function(str)
return { buffer = ev.buf, desc = str }
end
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client.server_capabilities.codeLensProvider then
vim.lsp.codelens.refresh({ bufnr = bufnr })
end
end,
})
local configs = require('lspconfig.configs')
local lspconfig = require("lspconfig")
local capabilities = vim.lsp.protocol.make_client_capabilities()
local servers = {
'gopls',
'nil_ls',
@ -30,39 +10,36 @@ local servers = {
for _, ls in ipairs(servers) do
lspconfig[ls].setup {
capabilities = capabilities,
on_attach = function(_, buf)
vim.api.nvim_set_option_value('omnifunc', 'v:lua.MiniCompletion.completefunc_lsp', {buf = buf})
end,
}
end
lspconfig.nixd.setup({
capabilities = capabilities,
cmd = { "nixd" },
settings = {
nixd = {
nixpkgs = { expr = "import <nixpkgs> { }" },
formatting = { command = { "nixfmt" } },
options = {},
},
},
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,
},
},
},
},
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,
},
},
},
},
})

View file

@ -16,7 +16,7 @@
system = final.system;
config.allowUnfree = true;
};
unstable = import inputs.nixpkgs-unstable {
nixpkgs-unstable = import inputs.nixpkgs-unstable {
system = final.system;
config.allowUnfree = true;
};