mirror of
https://github.com/elkowar/dots-of-war.git
synced 2024-12-25 13:42:23 +00:00
Cleanup vim
This commit is contained in:
parent
618010bd0c
commit
32c1044d90
5 changed files with 436 additions and 3 deletions
1
coc-settings.json
Symbolic link
1
coc-settings.json
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.vim/coc-settings.json
|
199
init.vim
199
init.vim
|
@ -1,3 +1,196 @@
|
|||
set runtimepath^=~/.vim runtimepath+=~/.vim/after
|
||||
let &packpath=&runtimepath
|
||||
source ~/.vimrc
|
||||
|
||||
" __ _(_)_ __ ___ _ __ ___
|
||||
" \ \ / / | '_ ` _ \| '__/ __|
|
||||
" \ V /| | | | | | | | | (__
|
||||
" \_/ |_|_| |_| |_|_| \___|
|
||||
|
||||
source ~/.config/nvim/plugins.vim
|
||||
|
||||
|
||||
if &shell =~# 'fish$'
|
||||
set shell=bash
|
||||
endif
|
||||
|
||||
let mapleader ="\<Space>"
|
||||
|
||||
|
||||
" Vanilla VIM configuration ------------------------------------ {{{
|
||||
|
||||
filetype plugin indent on
|
||||
syntax on
|
||||
|
||||
set foldmethod=marker
|
||||
set undodir=~/.vim/undo-dir
|
||||
set undofile
|
||||
set shortmess+=c " Don't give completion messages like 'match 1 of 2' or 'The only match'
|
||||
set hidden
|
||||
set encoding=utf-8
|
||||
set nonumber norelativenumber
|
||||
set nocompatible
|
||||
set cursorline
|
||||
|
||||
" May cause problems!
|
||||
if (has("termguicolors"))
|
||||
set termguicolors
|
||||
endif
|
||||
|
||||
" Indentation
|
||||
set shiftwidth=2
|
||||
set tabstop=2
|
||||
set backspace=indent,eol,start
|
||||
set autoindent smartindent noet expandtab
|
||||
set nowrap
|
||||
set noshowmode " hide the mode as shown by vim, because the status line does it better!
|
||||
|
||||
set completeopt=longest,menuone " Enable autocompletion
|
||||
set laststatus=2
|
||||
set noshowmode
|
||||
|
||||
|
||||
|
||||
set background=dark
|
||||
colorscheme gruvbox
|
||||
let g:onedark_terminal_italics=1
|
||||
hi LineNr ctermbg=NONE guibg=NONE
|
||||
hi Comment cterm=italic
|
||||
let &t_ut=''
|
||||
|
||||
" hide empty line ~'s
|
||||
highlight EndOfBuffer ctermfg=black ctermbg=black
|
||||
|
||||
if !has("nvim")
|
||||
set term=xterm-256color
|
||||
endif
|
||||
|
||||
" Clipboard support in WSL
|
||||
func! GetSelectedText()
|
||||
normal gv"xy
|
||||
let result = getreg("x")
|
||||
return result
|
||||
endfunc
|
||||
|
||||
if !has("clipboard") && executable("clip.exe")
|
||||
vnoremap <C-C> :call system('clip.exe', GetSelectedText())<CR>
|
||||
vnoremap <C-X> :call system('clip.exe', GetSelectedText())<CR>gvx
|
||||
endif
|
||||
|
||||
|
||||
" Mouse config
|
||||
set mouse=a
|
||||
if !has("nvim")
|
||||
if has("mouse_sgr")
|
||||
set ttymouse=sgr
|
||||
else
|
||||
set ttymouse=xterm2
|
||||
end
|
||||
end
|
||||
|
||||
if !has('gui_running')
|
||||
set t_Co=256
|
||||
endif
|
||||
|
||||
augroup basics
|
||||
autocmd!
|
||||
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o "Disables automatic commenting on newline:
|
||||
autocmd FileType vim setlocal foldmethod=marker
|
||||
|
||||
" file type assignments
|
||||
autocmd BufRead,BufNewFile *.ddl setlocal filetype=sql
|
||||
augroup END
|
||||
|
||||
highlight Pmenu ctermbg=black guibg=black
|
||||
|
||||
|
||||
" ===============
|
||||
" Basic remapping
|
||||
" ===============
|
||||
|
||||
" Split configs
|
||||
nnoremap <C-J> <C-W><C-J>
|
||||
nnoremap <C-K> <C-W><C-K>
|
||||
nnoremap <C-L> <C-W><C-L>
|
||||
nnoremap <C-H> <C-W><C-H>
|
||||
set splitbelow splitright
|
||||
|
||||
" Buffer switching
|
||||
noremap <silent> <leader>l :bnext<CR>
|
||||
noremap <silent> <leader>h :bprevious<CR>
|
||||
|
||||
" Disable default K mapping (would open man page of hovered word)
|
||||
nnoremap K <Nop>
|
||||
vnoremap K <Nop>
|
||||
|
||||
" }}}
|
||||
|
||||
" Plugin configuration --------------------------------------------------- {{{
|
||||
|
||||
|
||||
" Misc configuration ----------------------------------------------------- {{{
|
||||
|
||||
|
||||
autocmd BufReadPost * :DetectIndent
|
||||
let g:detectindent_preferred_expandtab = 1
|
||||
let g:detectindent_preferred_indent = 2
|
||||
|
||||
|
||||
let g:sneak#label = 1
|
||||
nmap <DEL> <Plug>Sneak_s
|
||||
nmap <S-DEL> <Plug>Sneak_S
|
||||
omap <DEL> <Plug>Sneak_s
|
||||
omap <S-DEL> <Plug>Sneak_S
|
||||
|
||||
" FZF showing previews
|
||||
command! -bang -nargs=? -complete=dir Files
|
||||
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
|
||||
|
||||
command! -bang -nargs=? -complete=dir HFiles
|
||||
\ call fzf#vim#files(<q-args>, {'source': 'ag --hidden --ignore .git -g ""'}, <bang>0)
|
||||
|
||||
let g:rust_clip_command = 'xclip -selection clipboard'
|
||||
let g:rustfmt_autosave = 1
|
||||
|
||||
let g:user_emmet_leader_key='<leader>e'
|
||||
let g:user_emmet_settings = { 'javascript.jsx' : { 'extends' : 'jsx' }, 'typescript.jsx' : { 'extends' : 'jsx' } }
|
||||
|
||||
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
|
||||
let g:qs_lazy_highlight = 1
|
||||
|
||||
|
||||
nnoremap <C-p> :Files<CR>
|
||||
|
||||
map <Leader>f <Plug>(easymotion-bd-f)
|
||||
map <Leader>s <Plug>(easymotion-overwin-f2)
|
||||
let g:EasyMotion_smartcase = 1
|
||||
|
||||
nmap / <Plug>(incsearch-forward)
|
||||
nmap ? <Plug>(incsearch-backward)
|
||||
|
||||
let g:signify_sign_delete = '-'
|
||||
|
||||
" Airline {{{
|
||||
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
let g:airline_powerline_fonts = 0
|
||||
|
||||
let g:airline_section_a = '%#__accent_bold#%{airline#util#wrap(airline#parts#mode(),0)}%#__restore__#%{airline#util#append(airline#parts#iminsert(),0)}'
|
||||
let g:airline_section_b = ''
|
||||
let g:airline_section_c = '%<%<%#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%{airline#util#wrap(airline#extensions#coc#get_status(),0)}%#__restore__#'
|
||||
let g:airline_section_y = ''
|
||||
let g:airline_section_z = '%4l% %3v'
|
||||
let g:airline_section_warning = '%{airline#extensions#whitespace#check()}%{airline#util#wrap(airline#extensions#coc#get_warning(),0)}'
|
||||
|
||||
let airline#extensions#coc#error_symbol = ''
|
||||
let airline#extensions#coc#warning_symbol = ''
|
||||
let airline#extensions#coc#stl_format_err = '%E{[%e(#%fe)]}'
|
||||
let airline#extensions#coc#stl_format_warn = '%W{[%w(#%fw)]}'
|
||||
|
||||
|
||||
let g:airline_theme='elkowars_gruvbox'
|
||||
|
||||
" }}}
|
||||
|
||||
" }}}
|
||||
|
||||
source ~/.config/nvim/whichkeyConfig.vim
|
||||
source ~/.config/nvim/lsp.vim
|
||||
" }}}
|
||||
|
|
60
lsp.vim
Normal file
60
lsp.vim
Normal file
|
@ -0,0 +1,60 @@
|
|||
" vim-jsx
|
||||
autocmd! BufRead,BufNewFile *.tsx setlocal syntax=javascript.jsx
|
||||
|
||||
|
||||
" make emmet behave well with JSX in JS and TS files
|
||||
let g:user_emmet_settings = { 'javascript': { 'extends': 'jsx' }, 'typescript': { 'extends': 'tsx' }}
|
||||
let g:user_emmet_mode='n'
|
||||
|
||||
|
||||
|
||||
" ? idk
|
||||
inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : <SID>check_back_space() ? "\<TAB>" : coc#refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
|
||||
|
||||
function! Show_documentation()
|
||||
if (index(['vim','help'], &filetype) >= 0)
|
||||
execute 'h '.expand('<cword>')
|
||||
else
|
||||
call CocAction('doHover')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
|
||||
" Show all diagnostics.
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~ '\s'
|
||||
endfunction
|
||||
|
||||
|
||||
" Add `:Format` command to format current buffer.
|
||||
command! -nargs=0 Format :call CocAction('format')
|
||||
command! -nargs=0 Prettier :CocCommand prettier.formatFile
|
||||
|
||||
"Close preview window when completion is done.
|
||||
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
|
||||
|
||||
setlocal formatprg=floskell\ --style\ chris-done
|
||||
|
||||
set signcolumn=yes
|
||||
set cmdheight=1
|
||||
set updatetime=300
|
||||
|
||||
" maybe helps coc?
|
||||
set nobackup
|
||||
set nowritebackup
|
||||
|
||||
|
||||
hi CocUnderline gui=undercurl term=undercurl
|
||||
hi CocErrorHighlight ctermfg=red guifg=#c4384b gui=undercurl term=undercurl
|
||||
hi CocWarningHighlight ctermfg=yellow guifg=#c4ab39 gui=undercurl term=undercurl
|
||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||
|
93
plugins.vim
Normal file
93
plugins.vim
Normal file
|
@ -0,0 +1,93 @@
|
|||
if empty(glob('~/.vim/autoload/plug.vim'))
|
||||
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
||||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
||||
endif
|
||||
|
||||
|
||||
call plug#begin('~/.vim/plugged')
|
||||
|
||||
Plug 'tpope/vim-repeat'
|
||||
|
||||
Plug 'junegunn/goyo.vim', {'on': 'Goyo'}
|
||||
Plug 'osyo-manga/vim-over', {'on': 'OverCommandLine'} " Substitute preview
|
||||
|
||||
Plug 'liuchengxu/vim-which-key'
|
||||
|
||||
if has('nvim') || has('patch-8.0.902')
|
||||
Plug 'mhinz/vim-signify'
|
||||
else
|
||||
Plug 'mhinz/vim-signify', { 'branch': 'legacy' }
|
||||
endif
|
||||
|
||||
Plug 'tpope/vim-fugitive'
|
||||
|
||||
Plug 'preservim/nerdcommenter'
|
||||
|
||||
Plug 'vim-airline/vim-airline-themes'
|
||||
Plug 'vim-airline/vim-airline'
|
||||
|
||||
Plug 'morhetz/gruvbox'
|
||||
|
||||
Plug 'godlygeek/tabular' " :Tab /regex can align code on occurrences of the given regex. I.e. :Tab /= aligns all = signs in a block.
|
||||
Plug 'tpope/vim-surround'
|
||||
|
||||
Plug 'easymotion/vim-easymotion' " press <leader>f [somekey] to have quick-movement to any occurrence of the key
|
||||
Plug 'christoomey/vim-tmux-navigator' " good integration with tmux pane switching
|
||||
Plug 'nathanaelkane/vim-indent-guides' " Can be toggled using <leader>ig (intent-guides)
|
||||
|
||||
" <C-n> to select current word. <C-n> to select next occurrence.
|
||||
" with multiple lines selected in Visual mode, <C-n> to insert cursor in each line. I not i to insert in Visual-mode.
|
||||
Plug 'terryma/vim-multiple-cursors'
|
||||
Plug 'hauleth/sad.vim' " Use siw instead of ciw. when using . afterwards, will find the next occurrence of the changed word and change it too
|
||||
Plug 'wellle/targets.vim' " more text objects. IE: cin) (change in next parens). generally better handling of surrounding objects.
|
||||
Plug 'haya14busa/incsearch.vim' " Show search result-highlights whilst typing the query
|
||||
|
||||
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Fuzzy file opener, use: :FZF or :FZF! for fullscreen
|
||||
Plug 'junegunn/fzf.vim'
|
||||
|
||||
Plug 'unblevable/quick-scope' " highlight targets when pressing f<character>
|
||||
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } } " :MarkdownPreview for live markdown preview
|
||||
|
||||
Plug 'jiangmiao/auto-pairs'
|
||||
|
||||
Plug 'junegunn/vim-peekaboo' " highlight jump points (f, t)
|
||||
|
||||
Plug 'machakann/vim-highlightedyank'
|
||||
|
||||
Plug 'ciaranm/detectindent'
|
||||
Plug 'pechorin/any-jump.vim'
|
||||
Plug 'justinmk/vim-sneak'
|
||||
Plug 'psliwka/vim-smoothie'
|
||||
" Language Plugins ----------------------------------------------------- {{{
|
||||
|
||||
Plug 'LnL7/vim-nix'
|
||||
|
||||
|
||||
Plug 'ap/vim-css-color'
|
||||
Plug 'pangloss/vim-javascript' " syntax highlighting JS
|
||||
Plug 'ianks/vim-tsx'
|
||||
Plug 'leafgarland/typescript-vim'
|
||||
Plug 'sheerun/vim-polyglot' " Syntax highlighting for most languages
|
||||
Plug 'mattn/emmet-vim'
|
||||
|
||||
Plug 'udalov/kotlin-vim'
|
||||
|
||||
Plug 'purescript-contrib/purescript-vim'
|
||||
|
||||
Plug 'HerringtonDarkholme/yats.vim' " typescript syntax highlighting
|
||||
Plug 'mxw/vim-jsx'
|
||||
|
||||
"" Haskell
|
||||
Plug 'neovimhaskell/haskell-vim'
|
||||
Plug 'Twinside/vim-hoogle', {'on': 'Hoogle'}
|
||||
|
||||
" Rust
|
||||
Plug 'rust-lang/rust.vim'
|
||||
Plug 'mattn/webapi-vim'
|
||||
|
||||
|
||||
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
" }}}
|
||||
call plug#end()
|
86
whichkeyConfig.vim
Normal file
86
whichkeyConfig.vim
Normal file
|
@ -0,0 +1,86 @@
|
|||
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
|
||||
vnoremap <silent> <leader> :<c-u>'WhichKeyVisual '<Space>'<CR>
|
||||
let g:which_key_map = {}
|
||||
call which_key#register('<Space>', "g:which_key_map")
|
||||
|
||||
let g:which_key_map = {
|
||||
\ 'h' : 'which_key_ignore', 'l' : 'which_key_ignore',
|
||||
\ 'f' : 'which_key_ignore', 's': 'which_key_ignore' ,
|
||||
\ 'c' : { 'name': '+comment_out' },
|
||||
\ 'e' : { 'name': '+emmet' },
|
||||
\ 'z' : { 'name': '+folds', 'c': ['foldclose', 'close fold'],
|
||||
\ 'o': ['foldopen', 'open fold'] ,
|
||||
\ }
|
||||
\ }
|
||||
|
||||
|
||||
" Maps for code actions
|
||||
let g:which_key_map['m'] = {
|
||||
\ 'name' : '+Code-actions' ,
|
||||
\ 'd' : [ ':call Show_documentation()' , 'show documentation' ] ,
|
||||
\ 's' : [ ':CocList -I symbols' , 'list symbols' ] ,
|
||||
\ 'o' : [ ':CocList outline' , 'show outline' ] ,
|
||||
\ 'c' : [ ':CocList commands' , 'show all coc-commands' ] ,
|
||||
\ 'g' : [ '<Plug>(coc-definition)' , 'go to definition' ] ,
|
||||
\ 't' : [ '<Plug>(coc-type-definition)' , 'show type definition' ] ,
|
||||
\ 'i' : [ '<Plug>(coc-implementation)' , 'show implementation' ] ,
|
||||
\ 'r' : [ '<Plug>(coc-references)' , 'show references' ] ,
|
||||
\ 'n' : [ '<Plug>(coc-rename)' , 'rename' ] ,
|
||||
\ 'F' : [ '<Plug>(coc-format-selected)' , 'format selection' ] ,
|
||||
\ 'f' : [ '<Plug>(coc-format)' , 'format file' ] ,
|
||||
\ 'v' : [ '<Plug>(coc-codeaction)' , 'apply codeaction' ] ,
|
||||
\ 'V' : [ '<Plug>(coc-fix-current)' , 'apply quickfix' ] ,
|
||||
\ 'e' : [ ':CocList diagnostics' , 'list all errors' ] ,
|
||||
\ 'L' : [ '<Plug>(coc-diagnostics-next)' , 'go to next error' ] ,
|
||||
\ 'H' : [ '<Plug>(coc-diagnostics-prev)' , 'go to prev error' ] ,
|
||||
\}
|
||||
|
||||
|
||||
let g:which_key_map['a'] = {
|
||||
\ 'name': '+Bookmarks',
|
||||
\ ' ' : ['<Plug>(coc-bookmark-toggle)' , 'toggle bookmark' ] ,
|
||||
\ 'a' : ['<Plug>(coc-bookmark-annotate)' , 'annotate bookmark' ] ,
|
||||
\ 'j' : ['<Plug>(coc-bookmark-next)' , 'next bookmark' ] ,
|
||||
\ 'k' : ['<Plug>(coc-bookmark-prev)' , 'prev bookmark' ] ,
|
||||
\ 'l' : [':CocList bookmark' , 'list bookmarks' ] ,
|
||||
\ 'c' : [':CocCommand bookmark.clearForCurrentFile' , 'clear for current file' ] ,
|
||||
\ 'C' : [':CocCommand bookmark.clearForAllFiles' , 'clear for all files' ]
|
||||
\}
|
||||
|
||||
" mappings for view and layout
|
||||
let g:which_key_map['v'] = {
|
||||
\ 'name' : '+view-and-layout',
|
||||
\ 'n' : [':set relativenumber!' , 'toggle relative numbers' ] ,
|
||||
\ 'm' : [':set nonumber! norelativenumber' , 'toggle numbers'] ,
|
||||
\ 'g' : [':Goyo | set linebreak' , 'toggle focus mode' ] ,
|
||||
\ 'i' : [':IndentGuidesToggle' , 'toggle indent guides' ] ,
|
||||
\ }
|
||||
|
||||
let g:which_key_map['b'] = {
|
||||
\ 'name': '+buffers' ,
|
||||
\ 'o' : ['Buffers' , 'select open buffer' ] ,
|
||||
\ 'c' : [':bdelete!' , 'close open buffer' ] ,
|
||||
\ 'w' : [':bwipeout!' , 'wipeout open buffer' ] ,
|
||||
\ }
|
||||
|
||||
let g:which_key_map['x'] = {
|
||||
\ 'name' : '+other',
|
||||
\ 'f' : ['NERDTreeToggle' , '<Ctrl+F> show file tree'],
|
||||
\ 'p' : ['FZF' , '<Ctrl+p> search file (c-v/c-x to open in split)' ] ,
|
||||
\ 'h' : [':History:' , 'search command history'],
|
||||
\ 'c' : [':Commands' , 'search through commands'],
|
||||
\ 's' : ['OverCommandLine', 'Substitute with preview'],
|
||||
\ 'y' : [':CocList -A --normal yank', 'Show yank history']
|
||||
\ }
|
||||
|
||||
" CocList -A --normal yank needs :CocInstall coc-yank
|
||||
|
||||
|
||||
|
||||
"nnoremap <silent> m :<c-u>WhichKey 'm'<CR>
|
||||
autocmd! VimEnter * :unmap <space>ig
|
||||
autocmd! FileType which_key
|
||||
autocmd! FileType which_key set laststatus=0 noshowmode noruler
|
||||
\| autocmd! BufLeave <buffer> set laststatus=2 showmode ruler
|
||||
set timeoutlen=200
|
||||
|
Loading…
Reference in a new issue