You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. let mapleader =","
  2. if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
  3. echo "Downloading junegunn/vim-plug to manage plugins..."
  4. silent !mkdir -p ~/.config/nvim/autoload/
  5. silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
  6. autocmd VimEnter * PlugInstall
  7. endif
  8. call plug#begin('~/.config/nvim/plugged')
  9. Plug 'morhetz/gruvbox'
  10. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  11. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  12. Plug 'junegunn/fzf.vim'
  13. Plug 'ap/vim-css-color'
  14. Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
  15. Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' }
  16. call plug#end()
  17. let g:airline_powerline_fonts=1
  18. " Some basics:
  19. set go=a
  20. set mouse=a
  21. set nohlsearch
  22. set clipboard+=unnamedplus
  23. set incsearch
  24. set ignorecase
  25. set smartcase
  26. set linebreak
  27. set noswapfile
  28. set nobackup
  29. set undodir=~/.config/nvim/undodir
  30. set undofile
  31. "let g:gruvbox_contrast_dark = 'hard'
  32. "if exists('+termguicolors')
  33. " let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  34. " let &t_8b = "\<Esc>[38;2;%lu;%lu;%lum"
  35. "endif
  36. "let g:gruvbox_invert_selection = '0'
  37. "colorscheme gruvbox
  38. "set background=dark
  39. nnoremap c "_c
  40. set nocompatible
  41. filetype plugin on
  42. syntax on
  43. set encoding=utf-8
  44. set number relativenumber
  45. " Indent marks
  46. "set listchars=tab:\|_
  47. "set list
  48. " Tab 2 spaces
  49. filetype plugin indent on
  50. set tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab
  51. " Disables automatic commenting on newline:
  52. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  53. " coc
  54. inoremap <silent><expr> <TAB>
  55. \ pumvisible() ? "\<C-n>" :
  56. \ <SID>check_back_space() ? "\<TAB>" :
  57. \ coc#refresh()
  58. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  59. function! s:check_back_space() abort
  60. let col = col('.') - 1
  61. return !col || getline('.')[col - 1] =~# '\s'
  62. endfunction
  63. nmap <leader>gd <Plug>(coc-definition)
  64. nmap <leader>gr <Plug>(coc-references)
  65. nmap <leader>rr <Plug>(coc-rename)
  66. nnoremap <leader>prw :CocSearch <C-R>=expand("<cword>")<CR><CR>
  67. inoremap <expr> <C-j> pumvisible() ? "\<Down>" : "\<C-j>"
  68. inoremap <expr> <C-k> pumvisible() ? "\<Up>" : "\<C-k>"
  69. " fzf remaps
  70. "nnoremap <C-p> :GFiles<CR>
  71. nnoremap <C-q> :GFiles<CR>
  72. nnoremap <C-a> :Files<CR>
  73. let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.5, 'highlight': 'Comment' } }
  74. " Spell-check set to <leader>o, 'o' for 'orthography':
  75. map <leader>o :setlocal spell! spelllang=en_au<CR>
  76. " Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
  77. set splitbelow splitright
  78. " Shortcutting split navigation, saving a keypress:
  79. nnoremap <C-h> <C-w>h
  80. nnoremap <C-j> <C-w>j
  81. nnoremap <C-k> <C-w>k
  82. nnoremap <C-l> <C-w>l
  83. " Check file in shellcheck:
  84. map <leader>s :!clear && shellcheck %<CR>
  85. " Replace all is aliased to S.
  86. nnoremap <c-s> :%s//g<Left><Left>
  87. " For chrome extension development
  88. " nnoremap <c-h> :set syntax=
  89. " Navigating with guides
  90. inoremap <leader><leader> <Esc>/<++><Enter>"_c4l
  91. vnoremap <leader><leader> <Esc>/<++><Enter>"_c4l
  92. map <leader><leader> <Esc>/<++><Enter>"_c4l
  93. " Remember last cursor position
  94. autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  95. " Copy entire document
  96. noremap <leader>y <Esc>ggyG<C-o>
  97. map <leader>y <Esc>ggyG<C-o>
  98. autocmd BufNewFile,BufRead *.gohtml set syntax=html