1

When running eslint --fix locally the files get formatted with no problem. However when saving a file within neovim with autocmd BufWritePre *.js,*ts,*tsx :CocCommand eslint.executeAutofix or by running :CocCommand eslint.executeAutofix inside vim, the files do not change. Please any help is appreciated, or if anyone could help me how to debug this issue would be great.

Installed extensions

coc-eslint
coc-json
coc-prettier
coc-tsserver

CocInfo

## versions

vim version: NVIM v0.7.2
node version: v16.17.1
coc.nvim version: 0.0.82-dbd0976c 2022-09-14 18:27:21 +0800
coc.nvim directory: /home/jiseung/.vim/plugged/coc.nvim
term: tmux
platform: linux

## Log of coc.nvim

2022-10-11T15:50:41.073 INFO (pid:47125) [plugin] - coc.nvim initialized with node: v16.17.1 after 134ms
2022-10-11T15:50:42.770 INFO (pid:47125) [attach] - receive notification: showInfo []
2022-10-11T15:50:57.116 INFO (pid:47125) [services] - registered service "eslint"
2022-10-11T15:50:57.116 INFO (pid:47125) [services] - LanguageClient ESLint state change: stopped => starting
2022-10-11T15:50:57.142 INFO (pid:47125) [services] - registered service "tsserver"
2022-10-11T15:50:57.159 INFO (pid:47125) [services] - service tsserver started
2022-10-11T15:50:57.213 INFO (pid:47125) [services] - LanguageClient ESLint state change: starting => running
2022-10-11T15:50:57.216 INFO (pid:47125) [services] - service eslint started
2022-10-11T15:50:58.653 INFO (pid:47125) [attach] - receive notification: runCommand [ 'eslint.executeAutofix' ]
2022-10-11T15:50:58.657 INFO (pid:47125) [attach] - Request action: doAutocmd [ 1, 8 ]
2022-10-11T15:51:05.810 INFO (pid:47125) [attach] - receive notification: showInfo []

Plugins

call plug#begin('~/.vim/plugged')

Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-fzy-native.nvim'
Plug 'gruvbox-community/gruvbox'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'mattn/emmet-vim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/playground'
Plug 'ThePrimeagen/harpoon'

call plug#end()

coc.vim

" Give more space for displaying messages.
set cmdheight=2

" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300

" Don't pass messages to |ins-completion-menu|.
set shortmess+=c

" Navigate completion
inoremap <expr> <C-j> coc#pum#visible() ? coc#pum#next(1) : "\<C-j>"
inoremap <expr> <C-k> coc#pum#visible() ? coc#pum#prev(1) : "\<C-k>"

" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> <C-k> <Plug>(coc-diagnostic-prev)
nmap <silent> <C-j> <Plug>(coc-diagnostic-next)

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>

function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  elseif (coc#rpc#ready())
    call CocActionAsync('doHover')
  else
    execute '!' . &keywordprg . " " . expand('<cword>')
  endif
endfunction

" Symbol renaming.
nmap <leader>r <Plug>(coc-rename)

" Formatting selected code.
xmap <leader>f  <Plug>(coc-format-selected)<CR>
nmap <leader>f  <Plug>(coc-format-selected)<CR>

" Add `:Format` command to format current buffer with language server
command! -nargs=0 Format :call CocAction('format')

" Add `:Prettier` command to format current buffer with prettier
command! -nargs=0 Prettier :CocCommand prettier.formatFile

" Add `:eslint` command to format current buffer with eslint
command! -nargs=0 Eslint :CocCommand eslint.executeAutofix

" Auto format on save
autocmd BufWritePre *.py,*.html :Format
autocmd BufWritePre *.css,*scss :Prettier
autocmd BufWritePre *.js,*ts,*tsx :Eslint

" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)

" Show all diagnostics.
nnoremap <silent><nowait> <leader>d  :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <leader>e  :<C-u>CocList extensions<cr>

coc-settings.json

{
  "eslint.enable": true,
  "eslint.autoFixOnSave": true
}

정지승
  • 43
  • 4

0 Answers0