diff --git a/nvimrc b/nvimrc index 6eb66e3..6a7ae2e 100644 --- a/nvimrc +++ b/nvimrc @@ -266,6 +266,7 @@ 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 diff --git a/vim/lua/nvim_cmp_config.lua b/vim/lua/nvim_cmp_config.lua index 3cb963c..bad5322 100644 --- a/vim/lua/nvim_cmp_config.lua +++ b/vim/lua/nvim_cmp_config.lua @@ -3,7 +3,7 @@ local cmp = require("cmp") cmp.setup({ completion = { - completeopt = "menu,menuone,noinsert,noselect", + completeopt = "menu,menuone,noselect", }, snippet = { expand = function(args) @@ -18,10 +18,32 @@ cmp.setup({ mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), ["C-y"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }), [""] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }), + -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#super-tab-like-mapping + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }), + [""] = function(fallback) + if not cmp.select_next_item() then + if vim.bo.buftype ~= "prompt" and has_words_before() then + cmp.complete() + else + fallback() + end + end + end, + [""] = function(fallback) + if not cmp.select_prev_item() then + if vim.bo.buftype ~= "prompt" and has_words_before() then + cmp.complete() + else + fallback() + end + end + end, }), sources = cmp.config.sources({ { name = "copilot", keyword_length = 0 }, diff --git a/vim/lua/treesitter_config.lua b/vim/lua/treesitter_config.lua index eabcb81..8d4ed4d 100644 --- a/vim/lua/treesitter_config.lua +++ b/vim/lua/treesitter_config.lua @@ -1,4 +1,5 @@ require("nvim-treesitter.configs").setup({ + -- TODO: only install needed ensure_installed = "all", highlight = { enable = true,