Advertisement
Advait08

TIDYMOUSE V1 VIMRC

Oct 2nd, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 11.45 KB | Source Code | 0 0
  1. " TIDYMOUSE V1
  2. " COC, GRUVBOX
  3. " I still dont understand some of the stuff
  4. " next goals: move from coc, understand all the plugins
  5.  
  6. " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
  7. " the call to :runtime you can find below.  If you wish to change any of those
  8. " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
  9. " will be overwritten everytime an upgrade of the vim packages is performed.
  10. " It is recommended to make changes after sourcing debian.vim since it alters
  11. " the value of the 'compatible' option.
  12.  
  13. runtime! debian.vim
  14.  
  15. " Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
  16. " This happens after /etc/vim/vimrc(.local) are loaded, so it will override
  17. " any settings in these files.
  18. " If you don't want that to happen, uncomment the below line to prevent
  19. " defaults.vim from being loaded.
  20. " let g:skip_defaults_vim = 1
  21.  
  22. " Uncomment the next line to make Vim more Vi-compatible
  23. " NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
  24. " options, so any other options should be set AFTER setting 'compatible'.
  25. "set compatible
  26.  
  27. " Vim5 and later versions support syntax highlighting. Uncommenting the next
  28. " line enables syntax highlighting by default.
  29. if has("syntax")
  30.   syntax on
  31. endif
  32.  
  33. " If using a dark background within the editing area and syntax highlighting
  34. " turn on this option as well
  35. set background=dark
  36.  
  37. " Uncomment the following to have Vim jump to the last position when
  38. " reopening a file
  39. "au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  40.  
  41. " Uncomment the following to have Vim load indentation rules and plugins
  42. " according to the detected filetype.
  43. filetype plugin on
  44.  
  45. " The following are commented out as they cause vim to behave a lot
  46. " differently from regular Vi. They are highly recommended though.
  47. "set showcmd        " Show (partial) command in status line.
  48. "set showmatch      " Show matching brackets.
  49. "set ignorecase     " Do case insensitive matching
  50. "set smartcase      " Do smart case matching
  51. "set incsearch      " Incremental search
  52. "set autowrite      " Automatically save before commands like :next and :make
  53. "set hidden     " Hide buffers when they are abandoned
  54. set mouse=a     " Enable mouse usage (all modes)
  55.  
  56. " Source a global configuration file if available
  57. if filereadable("/etc/vim/vimrc.local")
  58.   source /etc/vim/vimrc.local
  59. endif
  60.  
  61. set number relativenumber
  62.  
  63. call plug#begin()
  64.  
  65. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  66. Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'npm ci'}
  67.  
  68. Plug 'tpope/vim-sensible'
  69. Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
  70. Plug 'f-person/git-blame.nvim'
  71.  
  72. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  73. Plug 'junegunn/fzf.vim'
  74.  
  75. Plug 'preservim/nerdcommenter'
  76. Plug 'Xuyuanp/nerdtree-git-plugin'
  77. Plug 'ryanoasis/vim-devicons'
  78. Plug 'jbgutierrez/vim-better-comments'
  79.  
  80. Plug 'Yggdroot/indentLine'
  81. Plug 'preservim/nerdtree'
  82.  
  83. Plug 'vim-test/vim-test'
  84. Plug 'rstacruz/vim-closer'
  85.  
  86. Plug 'morhetz/gruvbox'
  87. Plug 'vim-airline/vim-airline'
  88. Plug 'vim-airline/vim-airline-themes'
  89.  
  90. Plug 'neovim/nvim-lspconfig'
  91. Plug 'mattn/emmet-vim'
  92. Plug 'tpope/vim-fugitive'
  93. Plug 'tpope/vim-surround'
  94. Plug 'simnalamburt/vim-mundo'
  95.  
  96. Plug 'HerringtonDarkholme/yats.vim'  "TS SYNTAX
  97.  
  98. call plug#end()
  99.  
  100. set termguicolors
  101.  
  102. colorscheme gruvbox
  103.  
  104. set signcolumn=yes
  105.  
  106. " airline
  107.   let g:airline_theme='wombat'
  108.   let g:airline_left_sep = ''
  109.   let g:airline_left_alt_sep = ''
  110.   let g:airline_right_sep = ''
  111.   let g:airline_right_alt_sep = ''
  112. "  let g:airline_symbols.branch = ''
  113. "  let g:airline_symbols.colnr = ' ℅:'
  114. "  let g:airline_symbols.readonly = ''
  115. "  let g:airline_symbols.linenr = ' :'
  116. "  let g:airline_symbols.maxlinenr = '☰ '
  117. "  let g:airline_symbols.dirty='⚡'
  118.  
  119.  
  120.  
  121. " Highlight opened file
  122.  function! IsNERDTreeOpen()        
  123.   return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
  124. endfunction
  125.  
  126. " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
  127. " file, and we're not in vimdiff
  128. function! SyncTree()
  129.   if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
  130.     NERDTreeFind
  131.     wincmd p
  132.   endif
  133. endfunction
  134.  
  135. " Highlight currently open buffer in NERDTree
  136. autocmd BufRead * call SyncTree()
  137.  
  138. " coc config
  139. let g:coc_global_extensions = [
  140.   \ 'coc-snippets',
  141.   \ 'coc-pairs',
  142.   \ 'coc-tsserver',
  143.   \ 'coc-eslint',
  144.   \ 'coc-prettier',
  145.   \ 'coc-json',
  146.   \ ]
  147.  
  148.  
  149. "Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
  150. "If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
  151. "(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
  152. if (empty($TMUX) && getenv('TERM_PROGRAM') != 'Apple_Terminal')
  153.   if (has("nvim"))
  154.     "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
  155.     let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  156.   endif
  157.   "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
  158.   "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
  159.   " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
  160.   if (has("termguicolors"))
  161.     set termguicolors
  162.   endif
  163. endif
  164.  
  165. " Use tab for trigger completion with characters ahead and navigate
  166. " NOTE: There's always complete item selected by default, you may want to enable
  167. " no select by `"suggest.noselect": true` in your configuration file
  168. " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
  169. " other plugin before putting this into your config
  170. inoremap <silent><expr> <TAB>
  171.       \ coc#pum#visible() ? coc#pum#next(1) :
  172.       \ CheckBackspace() ? "\<Tab>" :
  173.       \ coc#refresh()
  174. inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
  175.  
  176. " Make <CR> to accept selected completion item or notify coc.nvim to format
  177. " <C-g>u breaks current undo, please make your own choice
  178. inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
  179.                               \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
  180.  
  181. function! CheckBackspace() abort
  182.   let col = col('.') - 1
  183.   return !col || getline('.')[col - 1]  =~# '\s'
  184. endfunction
  185.  
  186. " Use <c-space> to trigger completion
  187. if has('nvim')
  188.   inoremap <silent><expr> <c-space> coc#refresh()
  189. else
  190.   inoremap <silent><expr> <c-@> coc#refresh()
  191. endif
  192.  
  193. " Use `[g` and `]g` to navigate diagnostics
  194. " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list
  195. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  196. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  197.  
  198. " GoTo code navigation
  199. nmap <silent> gd <Plug>(coc-definition)
  200. nmap <silent> gy <Plug>(coc-type-definition)
  201. nmap <silent> gi <Plug>(coc-implementation)
  202. nmap <silent> gr <Plug>(coc-references)
  203.  
  204. " Use K to show documentation in preview window
  205. nnoremap <silent> K :call ShowDocumentation()<CR>
  206.  
  207. function! ShowDocumentation()
  208.   if CocAction('hasProvider', 'hover')
  209.     call CocActionAsync('doHover')
  210.   else
  211.     call feedkeys('K', 'in')
  212.   endif
  213. endfunction
  214.  
  215. " Highlight the symbol and its references when holding the cursor
  216. autocmd CursorHold * silent call CocActionAsync('highlight')
  217.  
  218. " Symbol renaming
  219. nmap <leader>rn <Plug>(coc-rename)
  220.  
  221. " Formatting selected code
  222. xmap <leader>f  <Plug>(coc-format-selected)
  223. nmap <leader>f  <Plug>(coc-format-selected)
  224.  
  225. augroup mygroup
  226.   autocmd!
  227.   " Setup formatexpr specified filetype(s)
  228.   autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  229.   " Update signature help on jump placeholder
  230.   autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  231. augroup end
  232.  
  233. " Applying code actions to the selected code block
  234. " Example: `<leader>aap` for current paragraph
  235. xmap <leader>a  <Plug>(coc-codeaction-selected)
  236. nmap <leader>a  <Plug>(coc-codeaction-selected)
  237.  
  238. " Remap keys for applying code actions at the cursor position
  239. nmap <leader>ac  <Plug>(coc-codeaction-cursor)
  240. " Remap keys for apply code actions affect whole buffer
  241. nmap <leader>as  <Plug>(coc-codeaction-source)
  242. " Apply the most preferred quickfix action to fix diagnostic on the current line
  243. nmap <leader>qf  <Plug>(coc-fix-current)
  244.  
  245. " Remap keys for applying refactor code actions
  246. nmap <silent> <leader>re <Plug>(coc-codeaction-refactor)
  247. xmap <silent> <leader>r  <Plug>(coc-codeaction-refactor-selected)
  248. nmap <silent> <leader>r  <Plug>(coc-codeaction-refactor-selected)
  249.  
  250. " Run the Code Lens action on the current line
  251. nmap <leader>cl  <Plug>(coc-codelens-action)
  252.  
  253. " Map function and class text objects
  254. " NOTE: Requires 'textDocument.documentSymbol' support from the language server
  255. xmap if <Plug>(coc-funcobj-i)
  256. omap if <Plug>(coc-funcobj-i)
  257. xmap af <Plug>(coc-funcobj-a)
  258. omap af <Plug>(coc-funcobj-a)
  259. xmap ic <Plug>(coc-classobj-i)
  260. omap ic <Plug>(coc-classobj-i)
  261. xmap ac <Plug>(coc-classobj-a)
  262. omap ac <Plug>(coc-classobj-a)
  263.  
  264. " Remap <C-f> and <C-b> to scroll float windows/popups
  265. if has('nvim-0.4.0') || has('patch-8.2.0750')
  266.   nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  267.   nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  268.   inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  269.   inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  270.   vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  271.   vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  272. endif
  273.  
  274. " Use CTRL-S for selections ranges
  275. " Requires 'textDocument/selectionRange' support of language server
  276. nmap <silent> <C-s> <Plug>(coc-range-select)
  277. xmap <silent> <C-s> <Plug>(coc-range-select)
  278.  
  279. " Add `:Format` command to format current buffer
  280. command! -nargs=0 Format :call CocActionAsync('format')
  281.  
  282. " Add `:Fold` command to fold current buffer
  283. command! -nargs=? Fold :call     CocAction('fold', <f-args>)
  284.  
  285. " Add `:OR` command for organize imports of the current buffer
  286. command! -nargs=0 OR   :call     CocActionAsync('runCommand', 'editor.action.organizeImport')
  287.  
  288. " Add (Neo)Vim's native statusline support
  289. " NOTE: Please see `:h coc-status` for integrations with external plugins that
  290. " provide custom statusline: lightline.vim, vim-airline
  291. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  292.  
  293. " Mappings for CoCList
  294. " Show all diagnostics
  295. nnoremap <silent><nowait> <space>a  :<C-u>CocList diagnostics<cr>
  296. " Manage extensions
  297. nnoremap <silent><nowait> <space>e  :<C-u>CocList extensions<cr>
  298. " Show commands
  299. nnoremap <silent><nowait> <space>c  :<C-u>CocList commands<cr>
  300. " Find symbol of current document
  301. nnoremap <silent><nowait> <space>o  :<C-u>CocList outline<cr>
  302. " Search workspace symbols
  303. nnoremap <silent><nowait> <space>s  :<C-u>CocList -I symbols<cr>
  304. " Do default action for next item
  305. nnoremap <silent><nowait> <space>j  :<C-u>CocNext<CR>
  306. " Do default action for previous item
  307. nnoremap <silent><nowait> <space>k  :<C-u>CocPrev<CR>
  308. " Resume latest coc list
  309. nnoremap <silent><nowait> <space>p  :<C-u>CocListResume<CR>
  310.  
  311. " mine from here
  312. nnoremap <C-b> :NERDTreeToggle<CR>
  313. nnoremap <C-t> :below terminal<CR>
  314.  
  315. " nerdcommenter
  316. nmap <C-_> <Plug>NERDCommenterToggle
  317. vmap <C-_> <Plug>NERDCommenterToggle
  318.  
  319. " remember <c-d> to close terminal, <c-w><c-w> to switch between vim and terminal
  320.  
  321.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement