Skip to content

Commit

Permalink
Switch to coc for language server support
Browse files Browse the repository at this point in the history
* Replaces ALE with Coc,
* Adds Solargraph for Ruby, replacing the original rubocop integration,
* Adds JavaScript, HTML, CSS hinting (with eslint and prettier),
* Removes supertab, which is now redundant.
  • Loading branch information
nickcharlton committed Mar 23, 2020
1 parent bfa578e commit 1497dab
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
1 change: 1 addition & 0 deletions ruby/default-gems
Expand Up @@ -3,3 +3,4 @@ pry
rubocop
rubocop-rails
rubocop-performance
solargraph
7 changes: 7 additions & 0 deletions vim/coc-settings.json
@@ -0,0 +1,7 @@
{
"solargraph.diagnostics": true,
"css.validate": false,
"less.validate": false,
"scss.validate": false,
"wxss.validate": false
}
32 changes: 18 additions & 14 deletions vimrc
Expand Up @@ -118,6 +118,24 @@ if executable('ag')
endif
endif

""""
" coc.nvim "
""""
" use tab to trigger completion and pick the selected
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction

" format the current file with <leader>p
nmap <leader>p :CocCommand prettier.formatFile<CR>
""""""""""""""""""""
" Filetype Plugins "
""""""""""""""""""""
Expand All @@ -140,20 +158,6 @@ augroup vimrcEx
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile .{jscs,jshint,eslint}rc set filetype=json
autocmd FileType text,markdown,mkd,pandoc call lexical#init()

" ALE linting events
if g:has_async
set updatetime=1000
let g:ale_lint_on_text_changed = 0
autocmd CursorHold * call ale#Queue(0)
autocmd CursorHoldI * call ale#Queue(0)
autocmd InsertEnter * call ale#Queue(0)
autocmd InsertLeave * call ale#Queue(0)
let b:ale_fixers = {'javascript': ['prettier', 'eslint']}
let g:ale_fix_on_save = 1
else
echoerr "This requires NeoVim or Vim 8"
endif
augroup END

""""""""""""""""""""""""
Expand Down
17 changes: 11 additions & 6 deletions vimrc.bundles
Expand Up @@ -22,24 +22,33 @@ call plug#begin('~/.vim/bundle')

" Define bundles via Github repos
Plug 'airblade/vim-gitgutter'
Plug 'bmatcuk/coc-stylelintplus', {'do': 'yarn install --frozen-lockfile'}
Plug 'bogado/file-line'
Plug 'chemzqm/vim-jsx-improve'
Plug 'chriskempson/base16-vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'elixir-lang/vim-elixir'
Plug 'elzr/vim-json'
Plug 'ervandew/supertab'
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
Plug 'hashivim/vim-terraform'
Plug 'janko-m/vim-test'
Plug 'jparise/vim-graphql'
Plug 'keith/swift.vim'
Plug 'modille/groovy.vim'
Plug 'mxw/vim-jsx'
Plug 'neoclide/coc-css', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-eslint', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-html', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-prettier', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-solargraph', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
Plug 'pangloss/vim-javascript'
Plug 'pbrisbin/vim-mkdir'
Plug 'reedes/vim-lexical'
Plug 'sbdchd/vim-run'
Plug 'sebdah/vim-delve'
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-endwise'
Expand All @@ -56,8 +65,4 @@ Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'vim-ruby/vim-ruby'

if g:has_async
Plug 'w0rp/ale'
endif

call plug#end()

0 comments on commit 1497dab

Please sign in to comment.