Compare commits

...

5 Commits

Author SHA1 Message Date
Rob Watson 896039d13f feat(nvim): tmux cmp integration 2023-10-04 05:54:38 +02:00
Rob Watson 36763ac5f6 feat(nvim): snippet config 2023-10-04 05:54:38 +02:00
Rob Watson d123d084d7 fix(nvim): copilot_cmp behaviour 2023-10-04 05:54:38 +02:00
Rob Watson 0cd4cf6d40 fix(nvim): copilot_cmp tab completion 2023-10-04 05:54:38 +02:00
Rob Watson f3d8f6e5cd chore: prefer eza to exa 2023-10-04 05:54:38 +02:00
5 changed files with 36 additions and 18 deletions

5
nvimrc
View File

@ -262,8 +262,6 @@ runtime macros/matchit.vim
" load other plugins:
packadd! rust.vim " https://github.com/rust-lang/rust.vim.git
" TODO: replace with nvim_cmp:
packadd! tmux-complete.vim " https://github.com/wellle/tmux-complete.vim.git
packadd! vim-commentary " https://github.com/tpope/vim-commentary.git
packadd! vim-rails " https://github.com/tpope/vim-rails.git
packadd! vim-jsx-pretty " https://github.com/MaxMEllon/vim-jsx-pretty.git
@ -300,13 +298,16 @@ lua require "copilot_config"
packadd! nvim-cmp " https://github.com/hrsh7th/nvim-cmp.git
packadd! copilot-cmp " https://github.com/zbirenbaum/copilot-cmp.git
packadd! vim-vsnip " https://github.com/hrsh7th/vim-vsnip.git
packadd! vim-vsnip-integ " https://github.com/hrsh7th/vim-vsnip-integ.git
packadd! cmp-vsnip " https://github.com/hrsh7th/cmp-vsnip.git
packadd! cmp-nvim-lsp " https://github.com/hrsh7th/cmp-nvim-lsp.git
packadd! cmp-buffer " https://github.com/hrsh7th/cmp-buffer.git
packadd! cmp-path " https://github.com/hrsh7th/cmp-path.git
packadd! cmp-calc " https://github.com/hrsh7th/cmp-calc
packadd! cmp-tmux " https://github.com/andersevenrud/cmp-tmux.git
lua require "nvim_cmp_config"
lua require "snippet_config"
" LSP:
packadd! nvim-lspconfig " https://github.com/neovim/nvim-lspconfig.git

View File

@ -9,7 +9,7 @@ fi
pacman -S --needed --noconfirm base-devel \
git \
exa \
eza \
fzf \
tmux \
ripgrep \

View File

@ -1,10 +1,12 @@
local cmp = require("cmp")
-- local cmp_buffer = require("cmp_buffer")
-- https://github.com/zbirenbaum/copilot-cmp#tab-completion-configuration-highly-recommended
local has_words_before = function()
unpack = unpack or table.unpack
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
return false
end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil
end
cmp.setup({
@ -32,15 +34,13 @@ cmp.setup({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
["<Tab>"] = function(fallback)
if not cmp.select_next_item() then
if vim.bo.buftype ~= "prompt" and has_words_before() then
cmp.complete()
else
fallback()
end
["<Tab>"] = vim.schedule_wrap(function(fallback)
if cmp.visible() and has_words_before() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
else
fallback()
end
end,
end),
["<S-Tab>"] = function(fallback)
if not cmp.select_prev_item() then
if vim.bo.buftype ~= "prompt" and has_words_before() then
@ -62,19 +62,32 @@ cmp.setup({
end,
},
},
{ name = "tmux", option = { all_panes = true } },
{ name = "path" },
{ name = "calc" },
}),
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
require("copilot_cmp.comparators").prioritize,
cmp.config.compare.offset,
cmp.config.compare.score,
cmp.config.compare.recently_used,
-- require("cmp-under-comparator").under,
cmp.config.compare.locality,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
-- https://github.com/hrsh7th/nvim-cmp/wiki/Advanced-techniques#disabling-completion-in-certain-contexts-such-as-comments
enabled = function()
local context = require("cmp.config.context")
if vim.api.nvim_get_mode().mode == "c" then
return true
end
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
end,
formatting = {
fields = { "kind", "abbr", "menu" },
},

View File

@ -0,0 +1,4 @@
vim.api.nvim_set_keymap("i", "<TAB>", [[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>']], { expr = true })
vim.api.nvim_set_keymap("s", "<TAB>", [[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>']], { expr = true })
vim.api.nvim_set_keymap("i", "<S-TAB>", [[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>']], { expr = true })
vim.api.nvim_set_keymap("s", "<S-TAB>", [[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>']], { expr = true })

4
zshrc
View File

@ -96,8 +96,8 @@ alias kgrpcurl="kubectl run grpcurl --image networld/grpcurl --image-pull-policy
alias kgs="kubectl get svc -o wide"
alias kmplayer="kubectl run mplayer --image olmesm/mplayer-docker:latest --image-pull-policy=Always -it --rm -- sh"
alias kw="kubectl get events -w"
alias ll="exa -l --group-directories-first --git"
alias ls="exa --color=auto"
alias ll="eza -l --group-directories-first --git"
alias ls="eza --color=auto"
alias lsoftcpl="sudo lsof -nP -iTCP -sTCP:LISTEN"
alias mc="make check"
alias ng="noglob"