Skip to content

Commit

Permalink
getting close to cmp being perfect. but not quite
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnymeller committed May 4, 2024
1 parent 333699e commit 6e46401
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 40 deletions.
23 changes: 19 additions & 4 deletions dotfiles/nvim/lua/plugins/nvim-cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ cmp.setup({
entries = {
follow_cursor = true,
},
docs = {
auto_open = true,
},
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-d>"] = cmp.mapping.scroll_docs(-3),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<Tab>"] = cmp.mapping.confirm(),
["<C-CR>"] = cmp.mapping.confirm(),
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp_signature_help" },
Expand All @@ -45,6 +48,7 @@ cmp.setup({
}),
formatting = {
format = lspkind.cmp_format({
max_width = 60,
mode = "symbol_text",
menu = {
nvim_lsp_signature_help = "[SIG]",
Expand All @@ -62,6 +66,14 @@ cmp.setup({
sorting = {
priority_weight = 2.0,
comparators = {
-- always put signature help on top
function(entry1, entry2)
if entry1.source.name == "nvim_lsp_signature_help" then
return true
elseif entry2.source.name == "nvim_lsp_signature_help" then
return false
end
end,
require("copilot_cmp.comparators").prioritize,
cmp.config.compare.offset,
cmp.config.compare.exact,
Expand Down Expand Up @@ -90,10 +102,13 @@ cmp.setup({
nvim_lsp_signature_help = {
max_height = 15,
},
preselect = cmp.PreselectMode.Item,
preselect = cmp.PreselectMode.None,
completion = {
completeopt = "menu,menuone,noinsert",
},
experimental = {
ghost_text = true,
},
})

cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
Expand Down
19 changes: 1 addition & 18 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
url = "github:neovim/neovim";
flake = false;
};

# nixCats plugins
"plugins-jsonfly-nvim" = {
url = "github:Myzel394/jsonfly.nvim";
flake = false;
};
};

outputs =
Expand Down
13 changes: 13 additions & 0 deletions pkgs/build_nix_pkg_update/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs, ... }:

with pkgs;

writeShellApplication {
name = "build_nix_pkg_update";
runtimeInputs = [
bash
git
];

text = builtins.readFile ../../scripts/build_nix_pkg_update.sh;
}
1 change: 1 addition & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ pkgs }:
with pkgs;
{
build_nix_pkg_update = callPackage ./build_nix_pkg_update { };
discord_audio_share = callPackage ./discord_audio_share { };
kill_and_attach = callPackage ./kill_and_attach { };
screenshot_to_clipboard = callPackage ./screenshot_to_clipboard { };
Expand Down
17 changes: 5 additions & 12 deletions programs/ncvim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,27 @@ let
SchemaStore-nvim
autosave-nvim
catppuccin-nvim
cmp-cmdline
cmp-buffer
cmp-cmdline
cmp-git
leap-nvim
vim-repeat
cmp-nvim-lsp
cmp-nvim-lsp-signature-help
cmp-nvim-lua
cmp-path
cmp_luasnip
comment-nvim
copilot-lua
copilot-cmp
copilot-lua
custom-vim-plugins.leetcode-nvim
diffview-nvim
efmls-configs-nvim
pkgs.neovimPlugins.jsonfly-nvim
fidget-nvim
flash-nvim
gitsigns-nvim
gruvbox-nvim
harpoon2
image-nvim
indent-blankline-nvim
jsonfly-nvim
lspkind-nvim
lualine-nvim
luasnip
Expand All @@ -147,30 +144,27 @@ let
nvim-ts-autotag
nvim-web-devicons
oil-nvim
nvim-remote-containers
telescope-sg
plenary-nvim
rustaceanvim
sg-nvim
sniprun
telescope-live-grep-args-nvim
telescope-nvim
telescope-sg
tint-nvim
tmux-nvim
trouble-nvim
undotree
vim-be-good
vim-dadbod
vim-dadbod-completion
vim-dadbod-ui
vim-fugitive
vim-indent-object
vim-matchup
vim-repeat
vim-rhubarb
vim-sleuth
vim-surround
which-key-nvim
wilder-nvim
zk-nvim
];
};
Expand Down Expand Up @@ -357,4 +351,3 @@ forEachSystem (
inherit (utils) templates baseBuilder;
keepLuaBuilder = utils.baseBuilder luaPath;
}

13 changes: 13 additions & 0 deletions scripts/build_nix_pkg_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <package>"
exit 1
fi

PACKAGE_NAME="$1"

pushd "$HOME/dev/oss/nixpkgs" || exit
git fetch r-ryantm "auto-update/$PACKAGE_NAME"
git checkout FETCH_HEAD
nix build .#"$PACKAGE_NAME"

0 comments on commit 6e46401

Please sign in to comment.