mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-13 15:42:58 +01:00
update nvim config
This commit is contained in:
parent
a33d26d45d
commit
5c87ac9288
3 changed files with 62 additions and 7 deletions
|
@ -1,4 +1,41 @@
|
|||
local map = vim.api.nvim_set_keymap
|
||||
map = vim.api.nvim_set_keymap
|
||||
|
||||
function escape_keycode(keycode)
|
||||
return vim.api.nvim_replace_termcodes(keycode, true, true, true)
|
||||
end
|
||||
|
||||
local function check_back_space()
|
||||
local col = vim.fn.col(".") - 1
|
||||
return col <= 0 or vim.fn.getline("."):sub(col, col):match("%s")
|
||||
end
|
||||
|
||||
function tab_completion()
|
||||
if vim.fn.pumvisible() > 0 then
|
||||
return escape_keycode("<C-n>")
|
||||
end
|
||||
|
||||
if check_back_space() then
|
||||
return escape_keycode("<TAB>")
|
||||
end
|
||||
|
||||
return vim.fn["coc#refresh"]()
|
||||
end
|
||||
|
||||
function shift_tab_completion()
|
||||
if vim.fn.pumvisible() > 0 then
|
||||
return escape_keycode("<C-p>")
|
||||
else
|
||||
return escape_keycode("<C-h>")
|
||||
end
|
||||
end
|
||||
|
||||
function cr_completion()
|
||||
if vim.fn.pumvisible() > 0 then
|
||||
return vim.fn["coc#_select_confirm"]()
|
||||
else
|
||||
return escape_keycode("<CR>")
|
||||
end
|
||||
end
|
||||
|
||||
-- Getting stuck in ~~vim~~ terminal
|
||||
map("t", "<Esc>", "<C-\\><C-n>", {})
|
||||
|
@ -17,6 +54,10 @@ map("n", "*y", "\"*y", { noremap = true })
|
|||
map("n", "*p", "\"*p", { noremap = true })
|
||||
map("n", "*d", "\"*d", { noremap = true })
|
||||
|
||||
map("i", "<TAB>", "v:lua.tab_completion()", { expr = true })
|
||||
map("i", "<S-TAB>", "v:lua.shift_tab_completion()", { expr = true })
|
||||
map("i", "<CR>", "v:lua.cr_completion()", { expr = true })
|
||||
|
||||
-- symbol renaming
|
||||
map("n", "-n", "<Plug>(coc-rename)", { silent = true })
|
||||
-- apply AutoFix to problem on current line
|
||||
|
@ -47,4 +88,3 @@ map("n", "-d", "<Plug>(coc-diagnostic-next)", { silent = true })
|
|||
|
||||
-- Use -o to show outline
|
||||
map("n", "-o", ":CocList outline<CR>", { silent = true })
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
coc = {}
|
||||
|
||||
vim.g.coc_global_extensions = {
|
||||
"coc-clangd",
|
||||
"coc-fish",
|
||||
|
@ -18,16 +20,30 @@ local function check_back_space()
|
|||
return col <= 0 or vim.fn.getline("."):sub(col, col):match("%s")
|
||||
end
|
||||
|
||||
function tab_completion()
|
||||
function coc.tab_completion()
|
||||
if vim.fn.pumvisible() > 0 then
|
||||
return vim.api.nvim_replace_termcodes("<C-n>", true, true, true)
|
||||
return escape_keycode("<C-n>")
|
||||
end
|
||||
|
||||
if check_back_space() then
|
||||
return vim.api.nvim_replace_termcodes("<TAB>", true, true, true)
|
||||
return escape_keycode("<TAB>")
|
||||
end
|
||||
|
||||
return vim.fn["coc#refresh"]()
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<TAB>", "v:lua.tab_completion()", { expr = true, noremap = false })
|
||||
function coc.shift_tab_completion()
|
||||
if vim.fn.pumvisible() > 0 then
|
||||
return escape_keycode("<C-p>")
|
||||
else
|
||||
return escape_keycode("<C-h>")
|
||||
end
|
||||
end
|
||||
|
||||
function coc.cr_completion()
|
||||
if vim.fn.pumvisible() > 0 then
|
||||
return vim.fn["coc#_select_confirm"]()
|
||||
else
|
||||
return escape_keycode([[\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>]])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,6 @@ return require("packer").startup(function(use)
|
|||
"jiangmiao/auto-pairs",
|
||||
config = pconf("autopairs")
|
||||
}
|
||||
use "tpope/vim-endwise"
|
||||
use "vimwiki/vimwiki"
|
||||
use {
|
||||
"glacambre/firenvim",
|
||||
|
|
Loading…
Reference in a new issue