nvim-config

Log | Files | Refs | Submodules | README

commit 5e7b3da344768598c7cf2800fddefe2fdf5fe107
parent 2ad6ec852a4272b0f8834cb9a53a4ba321c94ee1
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date:   Wed,  8 Dec 2021 14:27:10 +0100

fix(completion): use better mappings

Diffstat:
Mafter/plugin/mappings.vim | 8+++++---
Mlua/completree-config.lua | 7+++----
Mlua/lsp_config.lua | 1+
Mlua/mappings.lua | 20++++++++++++++++++--
Mlua/plugins.lua | 3---
5 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/after/plugin/mappings.vim b/after/plugin/mappings.vim @@ -1,4 +1,4 @@ -" Last Change: 2021 Sep 10 +" Last Change: 2021 Dec 08 vnoremap <silent> < <gv vnoremap <silent> > >gv @@ -7,10 +7,12 @@ nnoremap <silent> Q @@ nnoremap <silent> yq :copen<CR> nnoremap <silent> yQ :cclose<CR> -inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" +inoremap <silent> <CR> <Cmd>lua cr_confirm()<CR> imap <expr> <Tab> v:lua.tab_complete() -snoremap <silent> <Tab> <cmd>lua require('luasnip').jump(1)<Cr> +smap <expr> <Tab> v:lua.tab_complete() + +smap <silent> <C-l> <Plug>luasnip-jump-next imap <expr> <S-Tab> pumvisible() ? "\<C-P>" : "\<S-TAB>" diff --git a/lua/completree-config.lua b/lua/completree-config.lua @@ -49,6 +49,7 @@ comp.setup { ocaml = lsp_completion, python = lsp_completion, nix = lsp_completion, + tex = lsp_completion, -- For git commit and text only do luasnip gitcommit = s.luasnip, @@ -89,21 +90,19 @@ local comment_tag = (function() ["%"] = "%%", } - return function(_, _, kind) + return function(_, _, _, kind) -- TODO(vigoux): Only works for preffix only commentstring - local cmt = api.nvim_buf_get_option(0, 'commentstring') + local cmt = api.nvim_buf_get_option(0, 'commentstring'):gsub("%%%%", "%%%%%%") local curline = api.nvim_get_current_line() local preffix local reg = string.format(cmt, ".*$"):gsub(".", regex_escape) - print(reg) if curline:match(reg) then -- Already commented preffix = t(kind .. "(vigoux): ") else preffix = t(string.format(cmt, " " .. kind .. "(vigoux): ")) end - return sn(nil, { preffix, i(1, "content") diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua @@ -132,6 +132,7 @@ local lsps = { }, sumneko_lua = (function() return { + on_attach = on_attach, settings = { Lua = { runtime = { diff --git a/lua/mappings.lua b/lua/mappings.lua @@ -12,9 +12,25 @@ function tab_complete() return rt '<C-N>' elseif vim.api.nvim_get_current_line():match("^%s*$") then return rt '<Tab>' - elseif luasnip.jumpable(1) then - return rt '<Plug>luasnip-jump-next' else return rt '<Plug>(complementree-complete)' end end + +local function feed(codes) + local keys = rt(codes) + vim.api.nvim_feedkeys(keys, 'n', true) +end + +function cr_confirm() + if vim.fn.pumvisible() == 1 then + feed '<C-Y>' + if luasnip.expand_or_locally_jumpable() then + vim.schedule(function() + luasnip.expand_or_jump() + end) + end + else + feed '<CR>' + end +end diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -73,9 +73,6 @@ return require"packer".startup(function(use) require'colorizer'.setup() end} use 'lewis6991/impatient.nvim' - use { "steelsojka/pears.nvim", config = function() - require "pears".setup() - end } -- Git because git use { 'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } }