Advertisement
Guest User

neovim config

a guest
Sep 15th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 7.91 KB | None | 0 0
  1. """""""""""""""""""""""
  2. " Basic Configuration "
  3. """""""""""""""""""""""
  4.  
  5. """ Leader Shortcuts
  6. "
  7. let mapleader=","   " leader is comma
  8. inoremap jk <esc>   " jk is escape
  9.  
  10. """ Spaces & Tabs
  11. "
  12. set expandtab     " No tabs
  13. set shiftwidth=2  " Number of spaces for indent
  14. set softtabstop=2 " number of spaces in tab when editing
  15. set tabstop=2     " number of visual spaces per TAB
  16. "" White spaces
  17. set listchars=tab:»·,trail:·
  18. set list          " Show whitespace as special chars - see listchars
  19.  
  20. """ Spelling
  21. "
  22. set spell spelllang=en_us
  23. set encoding=utf8 " UTF-8 by default
  24.  
  25. """ Indentation
  26. "
  27. set autoindent    " Carry over indenting from previous line
  28. set cindent       " Automatic program indenting
  29. set copyindent    " Make autoindent use the same chars as prev line
  30.  
  31. """ UI config
  32. "
  33. filetype indent on  " load filetype-specific indent files
  34. "set cursorline      " highlight current line
  35. set lazyredraw      " redraw only when we need to
  36. set number          " show line numbers
  37. set showmatch       " highlight matching [{()}]
  38. set wildmenu        " visual autocomplete for command menu
  39. set textwidth=100
  40. set colorcolumn=100
  41. set scrolloff=9999  " Keep working line in the center
  42.  
  43. """ Search
  44. "
  45. set hlsearch   " highlight matches
  46. set incsearch  " search as characters are entered
  47. "" turn off search highlight
  48. nnoremap <leader><space> :nohlsearch<CR>
  49.  
  50. """ Folding
  51. "
  52. set foldenable          " enable folding
  53. set foldlevelstart=10   " open third level fold by default
  54. set foldmethod=syntax
  55. set foldnestmax=10      " 10 nested fold max
  56. "" space open/closes folds
  57. nnoremap <space> za
  58.  
  59. """ Movement
  60. "
  61. "" move vertically by visual line
  62. nnoremap j gj
  63. nnoremap k gk
  64. "" move to beginning/end of line
  65. nnoremap B ^
  66. nnoremap E $
  67. " $/^ doesn't do anything
  68. nnoremap $ <nop>
  69. nnoremap ^ <nop>
  70.  
  71. """ Directories
  72. "
  73. set directory-=.  " Don't store temp files in cwd
  74. "" Annoying temporary files
  75. set backupdir=/tmp//,.
  76. set directory=/tmp//,.
  77. set undodir=/tmp//,.
  78.  
  79. """""""""""""""
  80. """ Hotkeys """
  81. """""""""""""""
  82. "
  83. """ Buffers
  84. map <C-l> :ls<CR>       " List buffers
  85. map <C-q> :bd %<CR>     " Close current buffer
  86. """ Reformatting
  87. nnoremap <Leader>r gq}  " Reformat paragraphs and list
  88.  
  89.  
  90. """"""""""""""""""""
  91. """ File configs """
  92. """"""""""""""""""""
  93. "
  94. """ Markdown
  95. autocmd BufRead,BufNewFile *.md
  96.       \ setlocal autoindent expandtab filetype=markdown
  97.       \ textwidth=100 wrap formatoptions=tcqn
  98. """ AsciiDoc
  99. autocmd BufRead,BufNewFile *.adoc
  100.       \ setlocal autoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2 filetype=asciidoc
  101.       \ textwidth=100 wrap formatoptions=tcqn
  102.       \ formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\\|^\\s*<\\d\\+>\\s\\+\\\\|^\\s*[a-zA-Z.]\\.\\s\\+\\\\|^\\s*[ivxIVX]\\+\\.\\s\\+
  103.       \ comments=s1:/*,ex:*/,://,b:#,:%,:XCOMM,fb:-,fb:*,fb:+,fb:.,fb:>
  104.  
  105. """"""""""""""""""""""""""""""
  106. """ Packet manager :: DEIN """
  107. """"""""""""""""""""""""""""""
  108.  
  109. """ HACK for vim-fish
  110. if &shell =~# 'fish$'
  111.     set shell=sh
  112.   endif
  113.  
  114. if &compatible
  115.   set nocompatible " Be improved
  116. endif
  117.  
  118. " Required:
  119. set runtimepath+=~/.dein/repos/github.com/Shougo/dein.vim
  120.  
  121. " Required:
  122. if dein#load_state('~/.dein')
  123.   call dein#begin('~/.dein')
  124.  
  125.   " Let dein manage dein
  126.   " Required:
  127.   call dein#add('~/.dein/repos/github.com/Shougo/dein.vim')
  128.  
  129.   call dein#add('Shougo/deoplete.nvim') " Completion engine
  130.  
  131.   call dein#add('zchee/deoplete-clang') " clang-driven completion for C++
  132.   call dein#add('rhysd/vim-clang-format')
  133.   call dein#add('octol/vim-cpp-enhanced-highlight')
  134.  
  135.   call dein#add('sebastianmarkow/deoplete-rust')
  136.   call dein#add('rust-lang/rust.vim')
  137.  
  138.   call dein#add('peterhoeg/vim-qml')
  139.   call dein#add('dag/vim-fish')
  140.  
  141.   call dein#add('morhetz/gruvbox') "Color scheme: gruvbox
  142.  
  143.   call dein#add('/usr/local/opt/fzf') " Fuzzy finder
  144.   call dein#add('junegunn/fzf.vim')
  145.  
  146.   call dein#add('scrooloose/nerdtree')
  147.  
  148.   call dein#add('airblade/vim-gitgutter')
  149.   call dein#add('MattesGroeger/vim-bookmarks')
  150.  
  151.   call dein#add('wakatime/vim-wakatime')
  152.  
  153.   " Required:
  154.   call dein#end()
  155.  
  156.   call dein#save_state()
  157. endif
  158.  
  159. " Required:
  160. filetype plugin indent on
  161. syntax enable
  162.  
  163. " If you want to install not installed plugins on startup.
  164. if dein#check_install()
  165.   call dein#install()
  166. endif
  167. "
  168. """ End dein Scripts """
  169. """"""""""""""""""""""""
  170.  
  171. """""""""""""""""""""""""""""
  172. """ Plugins configuration """
  173. """""""""""""""""""""""""""""
  174.  
  175. """ Deoplete """
  176. "
  177. let g:deoplete#enable_at_startup = 1
  178. let g:deoplete#sources#clang#libclang_path='/usr/local/Cellar/llvm/HEAD-3638207/lib/libclang.dylib'
  179. let g:deoplete#sources#clang#clang_header='/usr/local/Cellar/llvm/HEAD-3638207/lib/clang/8.0.0/include/'
  180. let g:deoplete#sources#clang#std={'cpp':'c++17'}
  181. let g:deoplete#sources#clang#flags = [
  182.       \ "-cc1",
  183.       \ "-triple", "x86_64-apple-macosx10.13.0",
  184.       \ "-discard-value-names",
  185.       \ "-mrelocation-model", "pic", "-pic-level", "2",
  186.       \ "-mthread-model", "posix",
  187.       \ "-dwarf-column-info",
  188.       \ "-debugger-tuning=lldb",
  189.       \ "-resource-dir", "/usr/local/Cellar/llvm/HEAD-3638207/lib/clang/8.0.0",
  190.       \ "-stdlib=libc++",
  191.       \ "-fdeprecated-macro",
  192.       \ "-ferror-limit", "20",
  193.       \ "-fmessage-length", "99",
  194.       \ "-stack-protector", "1",
  195.       \ "-fcxx-exceptions",
  196.       \ "-fexceptions",
  197.       \ "-fmax-type-align=16",
  198.       \ "-fdiagnostics-show-option"]
  199. "      \ "-mdisable-fp-elim",
  200. "      \ "-masm-verbose",
  201. "      \ "-munwind-tables",
  202. "      \ "-target-cpu", "penryn"
  203. "      \ "-target-linker-version", "278.4"
  204. "      \ "-fcolor-diagnostics",
  205.  
  206. let g:deoplete#sources#rust#racer_binary='~/.cargo/bin/racer'
  207. let g:deoplete#sources#rust#rust_source_path='~/ExtProjects/rust-src/src'
  208. let g:deoplete#sources#rust#show_duplicates=0
  209.  
  210. autocmd FileType rs nnoremap <buffer><Leader>cf :<C-u>RustFmt<CR>
  211. autocmd FileType rs vnoremap <buffer><Leader>cf :RustFmtRange<CR>
  212.  
  213. """ Color scheme """
  214. set termguicolors
  215. set background=dark
  216. colorscheme gruvbox
  217.  
  218. highlight Pmenu guibg=brown gui=bold
  219.  
  220. """""""""""""""""""""
  221. """ C++ Highlight """
  222. """""""""""""""""""""
  223. let g:cpp_class_scope_highlight = 1
  224. let g:cpp_member_variable_highlight = 1
  225. let g:cpp_class_decl_highlight = 1
  226. let g:cpp_experimental_template_highlight = 1
  227.  
  228. """ FZF """
  229. "
  230. nmap <Leader>ft :Tags<CR>
  231. nmap <Leader>fbt :BTags<CR>
  232. nmap <C-p> :Files<CR>
  233.  
  234. """ clang format """
  235. "
  236. let g:clang_format#code_style = "WebKit"
  237. let g:clang_format#style_options = {
  238.       \ "AccessModifierOffset" : -2,
  239.       \ "AllowShortIfStatementsOnASingleLine" : "true",
  240.       \ "AlwaysBreakTemplateDeclarations" : "true",
  241.       \ "Standard" : "C++11",
  242.       \ "CompactNamespaces" : "false",
  243.       \ "Cpp11BracedListStyle" : "true",
  244.       \ "FixNamespaceComments" : "true",
  245.       \ "BraceWrapping": {
  246.       \   "AfterClass": "true",
  247.       \   "AfterControlStatement": "true",
  248.       \   "AfterEnum": "true",
  249.       \   "AfterFunction": "true",
  250.       \   "AfterNamespace": "false",
  251.       \   "AfterStruct": "true",
  252.       \   "AfterUnion": "true",
  253.       \   "BeforeCatch": "true",
  254.       \   "BeforeElse": "true",
  255.       \   "IndentBraces": "false"
  256.       \ },
  257.       \ "PointerAlignment": "Left"
  258.       \}
  259.       "\ "SortUsingDeclarations" : "true",
  260. let g:clang_format#auto_format_on_insert_leave = 0
  261. autocmd FileType c,cpp nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
  262. autocmd FileType c,cpp vnoremap <buffer><Leader>cf :ClangFormat<CR>
  263.  
  264. """ NERD """
  265. "
  266. " Close NERD if it last window
  267. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
  268. map <F5> :NERDTreeToggle<CR>
  269.  
  270. " For conceal markers.
  271. if has('conceal')
  272.   set conceallevel=2 concealcursor=niv
  273. endif
  274.  
  275. """ Put these lines at the very end of your vimrc file.
  276. "
  277. """ Load all plugins now.
  278. """ Plugins need to be added to runtimepath before helptags can be generated.
  279. packloadall
  280. """ Load all of the helptags now, after plugins have been loaded.
  281. """ All messages and errors will be ignored.
  282. silent! helptags ALL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement