From 5993047779f02c3aab4b1e331189641fdef14f7d Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Tue, 27 Feb 2024 08:00:34 -0500 Subject: [PATCH] Updates to settings, particularly addinmg autopair plugin --- coc-settings.json | 11 ++++++-- ftplugin/markdown.vim | 2 ++ init.vim | 12 ++++++++- lua/autopair.lua | 62 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 lua/autopair.lua diff --git a/coc-settings.json b/coc-settings.json index 0ca774c..9660883 100644 --- a/coc-settings.json +++ b/coc-settings.json @@ -12,8 +12,15 @@ "clangd.path": "/usr/bin/clangd", "python.formatting.provider": "black", "python.formatting.blackArgs": ["-l","100"], - "coc.preferences.formatOnSaveFiletypes": ["python", "java", "rust"], + "coc.preferences.formatOnSaveFiletypes": ["python","java", "rust"], "java.inlayHints.parameterNames.enabled": "none", - "java.format.settings.url": "/home/alex.selimov/RedTop.xml" + "java.format.settings.url": "/home/alex.selimov/RedTop.xml", + "workspace.ignoredFolders": [ + "$HOME", + "$HOME/.cargo/**", + "$HOME/.rustup/**" + ], + "rust-analyzer.inlayHints.typeHints.enable": false, + "rust-analyzer.inlayHints.parameterHints.enable": false } diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index 7c04200..d094a71 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -17,4 +17,6 @@ inoremap ;pc ``````O inoremap ;cu - [ ] inoremap ;cc - [x] +set tw=200 +set colorcolumn= diff --git a/init.vim b/init.vim index b70b6a3..aa2c009 100644 --- a/init.vim +++ b/init.vim @@ -20,7 +20,8 @@ Plug 'christoomey/vim-tmux-navigator' Plug 'GCBallesteros/vim-textobj-hydrogen' Plug 'nvim-telescope/telescope-live-grep-args.nvim' Plug 'folke/todo-comments.nvim' -Plug 'rust-lang/rust' +Plug 'windwp/nvim-autopairs' +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " List ends here. Plugins become visible to Vim after this call. call plug#end() @@ -178,6 +179,9 @@ nnoremap Telescope live_grep grep_open_files=true theme=ivy vnoremap "zy:Telescope live_grep grep_open_files=true theme=ivy z " Change an option theme=ivy " +"Some coc.nvim bindings +nnoremap gd call CocActionAsync('jumpDefinition') + "Neomutt settings autocmd BufNewFile,BufRead /tmp/neomutt* set noautoindent filetype=mail wm=0 tw=0 nonumber nolist autocmd BufNewFile,BufRead ~/tmp/neomutt* set noautoindent filetype=mail wm=0 tw=0 nonumber nolist @@ -195,8 +199,14 @@ nnoremap lua require('iron') set formatoptions-=o +"autopair settings +lua require('autopair') + "todo-comments lua require("todo-comments").setup() "Default width for everything nonw set colorcolumn=100 set tw=100 + +"Some jumping +inoremap ; /<++>"_c4l diff --git a/lua/autopair.lua b/lua/autopair.lua new file mode 100644 index 0000000..acd6975 --- /dev/null +++ b/lua/autopair.lua @@ -0,0 +1,62 @@ +local remap = vim.api.nvim_set_keymap +local npairs = require('nvim-autopairs') + +npairs.setup({ map_bs = false, map_cr = false }) + +vim.g.coq_settings = { keymap = { recommended = false } } + +-- these mappings are coq recommended mappings unrelated to nvim-autopairs +remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) +remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) +remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) +remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) + +-- skip it, if you use another global object +_G.MUtils= {} + +MUtils.CR = function() + if vim.fn.pumvisible() ~= 0 then + if vim.fn.complete_info({ 'selected' }).selected ~= -1 then + return npairs.esc('') + else + return npairs.esc('') .. npairs.autopairs_cr() + end + else + return npairs.autopairs_cr() + end +end +remap('i', '', 'v:lua.MUtils.CR()', { expr = true, noremap = true }) + +MUtils.BS = function() + if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({ 'mode' }).mode == 'eval' then + return npairs.esc('') .. npairs.autopairs_bs() + else + return npairs.autopairs_bs() + end +end +remap('i', '', 'v:lua.MUtils.BS()', { expr = true, noremap = true }) + + +-- put this to setup function and press to use fast_wrap +npairs.setup({ + fast_wrap = {}, +}) + +-- change default fast_wrap +npairs.setup({ + fast_wrap = { + map = '', + chars = { '{', '[', '(', '"', "'" }, + pattern = [=[[%'%"%>%]%)%}%,]]=], + end_key = '$', + before_key = 'h', + after_key = 'l', + cursor_pos_before = true, + keys = 'qwertyuiopzxcvbnmasdfghjkl', + manual_position = true, + highlight = 'Search', + highlight_grey='Comment' + }, +}) + +npairs.remove_rule('`')