Compare commits

...

2 commits

Author SHA1 Message Date
Casper V. Kristensen cbcfd39229 vim: much better completions 2024-08-25 19:51:24 +02:00
Casper V. Kristensen d1b0fd8742 vim: cleanup 2024-08-25 19:50:49 +02:00

View file

@ -213,9 +213,7 @@
# Adds file type icons to Vim plugins. # Adds file type icons to Vim plugins.
# https://github.com/nvim-tree/nvim-web-devicons # https://github.com/nvim-tree/nvim-web-devicons
{ {plugin = nvim-web-devicons;}
plugin = nvim-web-devicons;
}
# Rearrange window layout using sway-like <Ctrl-Shift-{hjkl}> bindings. # Rearrange window layout using sway-like <Ctrl-Shift-{hjkl}> bindings.
# https://github.com/sindrets/winshift.nvim # https://github.com/sindrets/winshift.nvim
@ -313,9 +311,10 @@
# A completion engine plugin for neovim written in Lua. Completion # A completion engine plugin for neovim written in Lua. Completion
# sources are installed from external repositories and "sourced". # sources are installed from external repositories and "sourced".
# https://github.com/hrsh7th/nvim-cmp # https://github.com/hrsh7th/nvim-cmp
{ {plugin = cmp-buffer;}
plugin = cmp-nvim-lsp; {plugin = cmp-buffer;}
} {plugin = cmp-nvim-lsp;}
# {plugin = cmp-nvim-lsp-signature-help;}
{ {
plugin = nvim-cmp; plugin = nvim-cmp;
type = "lua"; type = "lua";
@ -323,6 +322,36 @@
# lua # lua
'' ''
local cmp = require("cmp") local cmp = require("cmp")
local compare = require("cmp.config.compare")
local lsp = require("cmp.types.lsp")
local kind = lsp.CompletionItemKind
local lsp_kind_priorities = {
[kind.Variable] = 1,
[kind.Value] = 2,
[kind.Field] = 3,
[kind.EnumMember] = 4,
[kind.Property] = 5,
[kind.TypeParameter] = 6,
[kind.Method] = 7,
[kind.Module] = 8,
[kind.Function] = 9,
[kind.Constructor] = 10,
[kind.Interface] = 11,
[kind.Class] = 12,
[kind.Struct] = 13,
[kind.Enum] = 14,
[kind.Constant] = 15,
[kind.Unit] = 16,
[kind.Keyword] = 17,
[kind.Snippet] = 18,
[kind.Color] = 19,
[kind.File] = 20,
[kind.Folder] = 21,
[kind.Event] = 22,
[kind.Operator] = 23,
[kind.Reference] = 24,
[kind.Text] = 25,
}
cmp.setup({ cmp.setup({
experimental = { experimental = {
ghost_text = true, ghost_text = true,
@ -345,8 +374,54 @@
-- whenever it has completion options available. -- whenever it has completion options available.
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
}), }),
performance = {
max_view_entries = 50, -- default 200
},
sorting = {
-- Comparators should return true when the first entry should
-- come EARLIER than the second entry, or nil if no pairwise
-- ordering preference from the comparator.
comparators = {
compare.offset,
compare.exact,
-- Put items that start with an underline last.
-- https://github.com/lukas-reineke/cmp-under-comparator
function(entry1, entry2)
local _, entry1_under = entry1.completion_item.label:find "^_+"
local _, entry2_under = entry2.completion_item.label:find "^_+"
entry1_under = entry1_under or 0
entry2_under = entry2_under or 0
if entry1_under > entry2_under then
return false
elseif entry1_under < entry2_under then
return true
end
end,
-- Order by LSP kind. Inspired by `compare.kind`:
-- https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/config/compare.lua
function(entry1, entry2)
local kind1 = entry1:get_kind()
local kind2 = entry2:get_kind()
kind1 = lsp_kind_priorities[kind1] or 100
kind2 = lsp_kind_priorities[kind2] or 100
if kind1 ~= kind2 then
local diff = kind1 - kind2
if diff < 0 then
return true
elseif diff > 0 then
return false
end
end
return nil
end,
compare.score,
},
},
sources = cmp.config.sources({ sources = cmp.config.sources({
-- https://github.com/hrsh7th/cmp-nvim-lsp-signature-help/issues/35
-- { name = "nvim_lsp_signature_help" },
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "buffer", keyword_length = 4 }, -- don't complete from buffer right away
}), }),
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
@ -767,15 +842,6 @@
require("lualine").setup({}) require("lualine").setup({})
''; '';
} }
# mini-nvim
# popup file-tree/viewer??
# nvim-colorizer-lua # show colours in colours
# vim-matchup # better %
# nvim-dap # debug adapter protocol
# nvim-dap-virtual-text # show variable values in-line
# salt-vim # salt syntax-highlighting
# https://github.com/JoosepAlviste/nvim-ts-context-commentstring
]; ];
extraPackages = [ extraPackages = [
nixpkgs-unstable.legacyPackages.${pkgs.system}.basedpyright nixpkgs-unstable.legacyPackages.${pkgs.system}.basedpyright