From 97dabf9a7e043c4b5d8c3fd2ff4bbb6c713686ee Mon Sep 17 00:00:00 2001 From: TiagoRG Date: Sat, 24 Feb 2024 21:04:19 +0000 Subject: [PATCH] Vim Update Signed-off-by: TiagoRG --- .config/nvim/after/plugin/lsp.lua | 22 +++++++++--- .config/nvim/after/plugin/luasnip.lua | 7 ---- .config/nvim/lua/tiagorg/remap.lua | 5 ++- .config/nvim/lua/tiagorg/set.lua | 25 ++++++------- .config/nvim/snippets/c.snippets | 51 +++++++++++---------------- .vimrc | 27 +++++++++----- .zsh/.zshrc | 2 ++ .zshenv | 1 + 8 files changed, 72 insertions(+), 68 deletions(-) diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index 8f16707..6eb3388 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -5,19 +5,31 @@ lsp.preset("recommended") -- Fix Undefined global 'vim' lsp.nvim_workspace() - +local luasnip = require("luasnip") local cmp = require('cmp') local cmp_select = { behavior = cmp.SelectBehavior.Select } local cmp_mappings = lsp.defaults.cmp_mappings({ [''] = cmp.mapping.select_prev_item(cmp_select), [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping.complete(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.confirm({ select = true }) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }) }) --- cmp_mappings[''] = nil --- cmp_mappings[''] = nil - lsp.setup_nvim_cmp({ mapping = cmp_mappings }) diff --git a/.config/nvim/after/plugin/luasnip.lua b/.config/nvim/after/plugin/luasnip.lua index 3d05bb8..fcaf713 100644 --- a/.config/nvim/after/plugin/luasnip.lua +++ b/.config/nvim/after/plugin/luasnip.lua @@ -1,12 +1,5 @@ require("luasnip.loaders.from_snipmate").load({ path = { "$HOME/.config/nvim/snippets/" } }) local ls = require("luasnip") -vim.keymap.set({"i"}, "", function() ls.expand() end, {silent = true}) vim.keymap.set({"i", "s"}, "", function() ls.jump( 1) end, {silent = true}) vim.keymap.set({"i", "s"}, "", function() ls.jump(-1) end, {silent = true}) - -vim.keymap.set({"i", "s"}, "", function() - if ls.choice_active() then - ls.change_choice(1) - end -end, {silent = true}) diff --git a/.config/nvim/lua/tiagorg/remap.lua b/.config/nvim/lua/tiagorg/remap.lua index 73ee3d1..9a0c534 100644 --- a/.config/nvim/lua/tiagorg/remap.lua +++ b/.config/nvim/lua/tiagorg/remap.lua @@ -35,7 +35,9 @@ vim.keymap.set("n", "", "cprevzz") vim.keymap.set("n", "k", "lnextzz") vim.keymap.set("n", "j", "lprevzz") -vim.keymap.set("n", "r", [[:%s/\<\>//gI]]) +vim.keymap.set("v", "rs", [[:s/\<\>//gI]]) +vim.keymap.set("n", "ra", [[:%s/\<\>//gI]]) +vim.keymap.set("n", "rc", [[:%s/\<\>//gcI]]) vim.keymap.set("n", "m", "!make > /dev/null", { silent = true }) @@ -49,5 +51,6 @@ vim.api.nvim_exec([[ augroup SearchHighlight autocmd! autocmd CmdlineLeave /,\? :nnoremap :nohls + autocmd CmdlineChanged /,\? :nnoremap :nohls augroup END ]], false) diff --git a/.config/nvim/lua/tiagorg/set.lua b/.config/nvim/lua/tiagorg/set.lua index bd0c2ba..c22193d 100644 --- a/.config/nvim/lua/tiagorg/set.lua +++ b/.config/nvim/lua/tiagorg/set.lua @@ -1,35 +1,30 @@ --- vim.opt.guicursor = "" +vim.g.mapleader = " " +vim.g.mouse = "a" --- vim.opt.clipboard = "unnamedplus" +vim.opt.updatetime = 50 +vim.opt.wrap = false vim.opt.nu = true vim.opt.relativenumber = true +vim.opt.scrolloff = 10 +vim.opt.signcolumn = "yes" +vim.opt.colorcolumn = "0" vim.opt.smartindent = true -vim.opt.wrap = false +vim.opt.hls = true +vim.opt.is = true +vim.opt.ic = true vim.opt.swapfile = false vim.opt.backup = false vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.undofile = true -vim.opt.hlsearch = true -vim.opt.incsearch = true - vim.opt.termguicolors = true - -vim.opt.scrolloff = 10 -vim.opt.signcolumn = "yes" vim.opt.isfname:append("@-@") vim.opt.guitablabel = "\\[%N\\]\\ %t\\ %M" -vim.opt.updatetime = 50 - -vim.opt.colorcolumn = "0" vim.g.copilot_node_command = "/usr/bin/nodenv" vim.g.copilot_assume_mapped = true - -vim.g.mapleader = " " -vim.g.mouse = "a" diff --git a/.config/nvim/snippets/c.snippets b/.config/nvim/snippets/c.snippets index a3f4d5c..55a37af 100644 --- a/.config/nvim/snippets/c.snippets +++ b/.config/nvim/snippets/c.snippets @@ -1,14 +1,12 @@ ## Main # main snippet main - int main(int argc, char *argv[]) - { + int main(int argc, char *argv[]) { ${0} } # main(void) snippet mainn - int main(void) - { + int main(void) { ${0} } ## @@ -141,15 +139,13 @@ snippet do ## Functions # function definition snippet fun - ${1:void} ${2:function_name}(${3}) - { - ${4} + ${1:void} ${2:function_name}(${3}) { + ${0} } # function definition with zero parameters snippet fun0 - ${1:void} ${2:function_name}() - { - ${3} + ${1:void} ${2:function_name}() { + ${0} } # function definition with Doxygen documentation snippet dfun0 @@ -159,15 +155,13 @@ snippet dfun0 * * \return ${3:Return parameter description} */ - ${4:void} ${5:function_name}() - { - ${6} + ${4:void} ${5:function_name}() { + ${0} } # function definition with one parameter snippet fun1 - ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}) - { - ${5} + ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}) { + ${0} } # function definition with one parameter with Doxygen documentation snippet dfun1 @@ -178,15 +172,13 @@ snippet dfun1 * \param $3 ${4:Parameter description} * \return ${5:Return parameter description} */ - ${6:void} ${7:function_name}(${8:Type} ${3:Parameter}) - { - ${9} + ${6:void} ${7:function_name}(${8:Type} ${3:Parameter}) { + ${0} } # function definition with two parameters snippet fun2 - ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}) - { - ${7} + ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}) { + ${0} } # function definition with two parameters with Doxygen documentation snippet dfun2 @@ -198,15 +190,13 @@ snippet dfun2 * \param $5 ${6:Parameter description} * \return ${7:Return parameter description} */ - ${8:void} ${9:function_name}(${10:Type} ${3:Parameter}, ${11:Type} ${5:Parameter}) - { - ${12} + ${8:void} ${9:function_name}(${10:Type} ${3:Parameter}, ${11:Type} ${5:Parameter}) { + ${0} } # function definition with three parameters snippet fun3 - ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}, ${7:Type} ${8:Parameter}) - { - ${9} + ${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}, ${7:Type} ${8:Parameter}) { + ${0} } # function definition with three parameters with Doxygen documentation snippet dfun3 @@ -219,9 +209,8 @@ snippet dfun3 * \param $7 ${8:Parameter description} * \return ${9:Return parameter description} */ - ${10:void} ${11:function_name}(${12:Type} ${3:Parameter}, ${13:Type} ${5:Parameter}, ${14:Type} ${7:Parameter}) - { - ${15} + ${10:void} ${11:function_name}(${12:Type} ${3:Parameter}, ${13:Type} ${5:Parameter}, ${14:Type} ${7:Parameter}) { + ${0} } # function declaration snippet fund diff --git a/.vimrc b/.vimrc index 78b0bf0..323482a 100644 --- a/.vimrc +++ b/.vimrc @@ -1,16 +1,22 @@ -syntax on -colorscheme onedark - set nu set relativenumber +set signcolumn=yes +set colorcolumn=80 + +set smartindent set tabstop=4 set shiftwidth=4 set ls=2 -set hlsearch -set incsearch + +set hls +set is +set ic set scrolloff=10 -let g:mapleader = " " +let g:mapleader=" " + +syntax on +colorscheme onedark nnoremap w :w nnoremap e :E @@ -33,12 +39,15 @@ vnoremap d "_d nnoremap Q @@ -nnoremap r :%s/\<\>//gI +vnoremap rs :s/\<\>//gI +nnoremap ra :%s/\<\>//gI +nnoremap rc :%s/\<\>//gcI nnoremap m :!make augroup SearchHighlight - autocmd! - autocmd CmdlineLeave /,\? :nnoremap :nohls + autocmd! + autocmd CmdlineLeave /,\? :nnoremap :nohls + autocmd CmdlineChanged /,\? :nnoremap :nohls augroup END diff --git a/.zsh/.zshrc b/.zsh/.zshrc index 9c6bbd7..1d2d8e6 100644 --- a/.zsh/.zshrc +++ b/.zsh/.zshrc @@ -323,3 +323,5 @@ export CPATH=/home/tiagorg/.local/include:/opt/pic32mx/include:$CPATH # For C++ only: CPLUS_INCLUDE_PATH # For Obj-C: OBJC_INCLUDE_PATH export LIBRARY_PATH=/home/tiagorg/.local/lib:$LIBRARY_PATH + +export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh diff --git a/.zshenv b/.zshenv index e20c7a8..599f0d5 100644 --- a/.zshenv +++ b/.zshenv @@ -1 +1,2 @@ ZDOTDIR=/home/tiagorg/.zsh +. "$HOME/.cargo/env"