Skip to content

Commit

Permalink
vimrc: improvements while working on the LSP branch
Browse files Browse the repository at this point in the history
  • Loading branch information
yml committed Sep 5, 2018
1 parent c18d0a2 commit e1017b1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 73 deletions.
9 changes: 5 additions & 4 deletions _bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ if [[ -d /usr/local/go/bin/ ]]; then
export PATH=/usr/local/go/bin/:$PATH
fi

if hash nvim 2>/dev/null; then
# if ag is available use it by default for FZF
[[ -x $(command -v ag) ]] && export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'

if [ -x $(command -v nvim) ]; then
# nvim
export EDITOR=nvim
export VISUAL=nvim
Expand All @@ -155,9 +158,7 @@ else
fi

# remap caps lock to escape
if setxkbmap -version >/dev/null 2>&1; then
setxkbmap -option "caps:swapescape"
fi
[[ -x $(command -v setxkbmap) ]] && setxkbmap -option "caps:swapescape"

# Set my GPG key
export GPGKEY=2F74DA04
Expand Down
1 change: 1 addition & 0 deletions _gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/__pycache__/
*.pyc
*.swp
*.swo
Expand Down
119 changes: 50 additions & 69 deletions _vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ endif
" Plug install packages
"*****************************************************************************
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Expand All @@ -45,6 +44,7 @@ Plug 'tomasiser/vim-code-dark'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'vimwiki/vimwiki'

"*****************************************************************************
" Experimental LSP completion
"*****************************************************************************"
Expand Down Expand Up @@ -112,32 +112,54 @@ command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` for fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
"*****************************************************************************"

" Go Lang Bundle
"*****************************************************************************"
if executable('go')
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
augroup FileType go
autocmd!
autocmd FileType go nmap <localleader>d <Plug>(go-def)
autocmd FileType go nmap <localleader>k <Plug>(go-doc)
autocmd FileType go nmap <localleader>dv <Plug>(go-def-vertical)
autocmd FileType go nmap <localleader>kv <Plug>(go-doc-vertical)
autocmd FileType go nmap <localleader>kb <Plug>(go-doc-browser)
autocmd FileType go nmap <localleader>i <Plug>(go-info)
autocmd FileType go nmap <localleader>r <Plug>(go-run)
autocmd FileType go nmap <localleader>b <Plug>(go-build)
autocmd FileType go nmap <localleader>t <Plug>(go-test)
augroup END
endif

if has('nvim')
Plug 'neomake/neomake'
let g:neomake_verbose = 0

autocmd! BufWritePost * Neomake
if executable("flake8") && executable("pep8")
let g:neomake_python_enabled_makers = ['flake8', 'pep8',]
let g:neomake_python_flake8_maker = { 'args': ['--ignore=E115,E266,E501'], }
let g:neomake_python_pep8_maker = { 'args': ['--max-line-length=100', '--ignore=E115,E266'], }
endif
" javascript linting
if executable("eslint")
let g:neomake_javascript_enabled_makers = ['eslint']
let g:neomake_javascript_eslint_exe = '/home/yml/gopath/src/bitbucket.org/yml/gobby/frontend/node_modules/.bin/eslint'
endif
if executable("npm")
" (optional) javascript completion
Plug 'roxma/nvim-cm-tern', {'do': 'npm install'}
endif
endif
"*****************************************************************************"
" gutter plugin
"*****************************************************************************"
" Always show up the sign column
set signcolumn="yes"

" if has('nvim')
" Plug 'neomake/neomake'
" let g:neomake_verbose = 1

" autocmd! BufWritePost * Neomake
" let g:neomake_python_pycodestyle_maker = { 'args': ['--ignore=E501'], }
" let g:neomake_python_flake8_maker = { 'args': ['--ignore=E115,E266,E501'], }
" let g:neomake_python_pydocstyle_maker = { 'args': ['--ignore=D101,D102'], }
" let g:neomake_python_pylint_maker = { 'args': ['--ignore=C0111'], }
" " if executable("flake8") && executable("pep8")
" " let g:neomake_python_enabled_makers = ['flake8', 'pep8']
" " let g:neomake_python_flake8_maker = { 'args': ['--ignore=E115,E266,E501'], }
" " let g:neomake_python_pep8_maker = { 'args': ['--max-line-length=100', '--ignore=E115,E266'], }
" " endif
" " javascript linting
" if executable("eslint")
" let g:neomake_javascript_enabled_makers = ['eslint']
" let g:neomake_javascript_eslint_exe = '/home/yml/gopath/src/bitbucket.org/yml/gobby/frontend/node_modules/.bin/eslint'
" endif
" if executable("npm")
" " (optional) javascript completion
" Plug 'roxma/nvim-cm-tern', {'do': 'npm install'}
" endif
" endif


call plug#end()
Expand All @@ -146,25 +168,8 @@ call plug#end()
" Completion
"*****************************************************************************"

set completeopt-=preview
"set completeopt-=preview
set shortmess+=co
" Tab completion
let g:asyncomplete_auto_popup = 0
let g:asyncomplete_remove_duplicates = 1

function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction

inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ asyncomplete#force_refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" Force refresh completion
imap <c-space> <Plug>(asyncomplete_force_refresh)
"*****************************************************************************
" Basic Setup
"*****************************************************************************"
Expand All @@ -175,12 +180,15 @@ set breakindent
" Highlight the cursorline
set cursorline

" Reload the file if it has been changed outside vim
set autoread


" Path
set path+=**
" Encoding
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set wildignore=*.swp,*.bak,*.pyc,*.class
set wildmode=list:longest,full

Expand Down Expand Up @@ -262,7 +270,6 @@ set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
"*****************************************************************************
" Expand the current directory
ab <expr> %% expand('%:p:h')

iab #! #!/usr/bin/env
iab @@ yann.malet@gmail.com

Expand Down Expand Up @@ -366,14 +373,6 @@ let g:vimwiki_ext2syntax = {'.md': 'markdown', '.mkd': 'markdown', '.wiki': 'med
"*****************************************************************************
" Autocmd Rules
"*****************************************************************************
augroup vimrc-jump-last-position
autocmd!
" jump to last position
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" remove white spaces
autocmd BufWritePre * call <SID>FixWhitespace(0, line("$"))
augroup END

" txt
augroup vimrc-wrapping
autocmd!
Expand Down Expand Up @@ -441,28 +440,10 @@ augroup virmc-htmldjango
augroup END

" gopass
augroup virmc-htmldjango
augroup virmc-gopass
autocmd!
au BufNewFile,BufRead /dev/shm/gopass.* setlocal noswapfile nobackup noundofile
augroup END

" Set the filetype to yaml for salt's `.sls` extension
au BufRead,BufNewFile *.sls set filetype=yaml

if executable("go")
augroup FileType go
autocmd!
autocmd FileType go nmap <localleader>d <Plug>(go-def)
autocmd FileType go nmap <localleader>k <Plug>(go-doc)
autocmd FileType go nmap <localleader>dv <Plug>(go-def-vertical)
autocmd FileType go nmap <localleader>kv <Plug>(go-doc-vertical)
autocmd FileType go nmap <localleader>kb <Plug>(go-doc-browser)
autocmd FileType go nmap <localleader>i <Plug>(go-info)
autocmd FileType go nmap <localleader>r <Plug>(go-run)
autocmd FileType go nmap <localleader>b <Plug>(go-build)
autocmd FileType go nmap <localleader>t <Plug>(go-test)
augroup END
endif

" Reload the file if it has been changed outside vim
set autoread

0 comments on commit e1017b1

Please sign in to comment.