处理函数 SwitchFlowOrTsLsps nvim windows 10 时检测到错误

问题描述

您好,我尝试输入一个 js 文件,但在输入时出现此错误

                Error detected while processing function SwitchFlowOrTsLsps:
line    4:
E121: Undefined variable: state
E15: Invalid expression: (tsserver.state == 'disabled')

尝试在不同的文件(例如maps、plugin 或plugin config)中找到告诉我的那一行,最后一个是我在其中找到的那一行,之前我没有遇到此错误,因为我只输入了py, cpp 和 java 扩展文件我有 coc,但不要为此下载任何东西,我也将风筝安装为自动完成插件

" HTML,JSX
let g:closetag_filenames = '*.html,*.js,*.jsx,*.ts,*.tsx'
" Lightlane
let g:lightline = {
      \ 'active': {
      \   'left': [['mode','paste'],[],['relativepath','modified']],\   'right': [['kitestatus'],['filetype','percent','lineinfo'],['gitbranch']]
      \ },\ 'inactive': {
      \   'left': [['inactive'],['relativepath']],\   'right': [['bufnum']]
      \ },\ 'component': {
      \   'bufnum': '%n',\   'inactive': 'inactive'
      \ },\ 'component_function': {
      \   'gitbranch': 'fugitive#head',\   'cocstatus': 'coc#status'
      \ },\ 'colorscheme': 'gruvBox',\ 'subseparator': {
      \   'left': '',\   'right': ''
      \ }
      \}

"  nerdtree
let NERDTreeShowHidden=1
let NERDTreeQuitOnopen=1
let NERDTreeAutoDeleteBuffer=1
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let NERDTreeShowLineNumbers=1
let NERDTreeMapOpenInTab='\t'
let g:javascript_plugin_flow = 1

" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsSnippetDirectories=[$HOME.'/config/.vim/UltiSnips']
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<S-tab>"

" deoplete
let g:deoplete#enable_at_startup = 1
let g:neosnippet#enable_completed_snippet = 1
" kite
let g:kite_supported_lenguages = ['javascript','python']

" coc
autocmd FileType python let b:coc_suggest_disable = 1
autocmd FileType javascript let b:coc_suggest_disable = 1
autocmd FileType scss setl iskeyword+=@-@

command! -bang -nargs=? -complete=dir GFiles
  \ call fzf#vim#gitfiles(<q-args>,fzf#vim#with_preview(),<bang>0)

command! -bang -nargs=* Ag
  \ call fzf#vim#ag(<q-args>,<bang>0)

command! -bang -nargs=? -complete=dir Files
  \ call fzf#vim#files(<q-args>,<bang>0)

" if hidden is not set,TextEdit might fail.
set hidden

" Some servers have issues with backup files,see #649
set nobackup
set Nowritebackup

" Better display for messages
set cmdheight=2

" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300

" don't give |ins-completion-menu| messages.
set shortmess+=c

" always show signcolumns
set signcolumn=yes

" fugitive always vertical diffing
set diffopt+=vertical

" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()

" Remap keys for gotos
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)

" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')

autocmd BufEnter *.js :silent let myIndex = SearchPatternInFile("@flow") | call SwitchFlowOrTsLsps(myIndex)
autocmd BufEnter *.jsx :silent let myIndex = SearchPatternInFile("@flow") | call SwitchFlowOrTsLsps(myIndex)

function! SwitchFlowOrTsLsps(flowIndex)
  silent let stats = CocAction("extensionStats")
  silent let tsserver = get(filter(copy(stats),function('FindTsServer')),0)
  if(a:flowIndex == 0)
    if(tsserver.state == 'disabled')
      call CocActionAsync("toggleExtension","coc-tsserver")
    endif
  else
    if(tsserver.state == 'activated')
      call CocActionAsync("toggleExtension","coc-tsserver")
    endif
  endif
endfunction

function! FindTsServer(idx,value) 
  return a:value.id == 'coc-tsserver'
endfunction

let $FZF_DEFAULT_OPTS='--layout=reverse'
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
function! FloatingFZF()
  let buf = nvim_create_buf(v:false,v:true)
  call setbufvar(buf,'&signcolumn','no')
  let height = float2nr((&lines - 3) / 2)
  let width = float2nr(&columns - (&columns * 2 / 10))
  let col = float2nr((&columns - width) / 2)
  let row = float2nr((&lines - height) / 2)
  let opts = {
        \ 'relative': 'editor',\ 'row': row,\ 'col': col,\ 'width': width,\ 'height': height
        \ }
  call nvim_open_win(buf,v:true,opts)
endfunction

function! SearchPatternInFile(pattern)
    " Save cursor position.
    let save_cursor = getcurpos()

    " Set cursor position to beginning of file.
    call cursor(0,0)

    " Search for the string 'hello' with a flag c.  The c flag means that a
    " match at the cursor position will be accepted.
    let search_result = search(a:pattern,"c")

    " Set the cursor back at the saved position.  The setpos function was
    " used here because the return value of getcurpos can be used directly
    " with it,unlike the cursor function.
    call setpos('.',save_cursor)

    " If the search function didn't find the pattern,it will have
    " returned 0,thus it wasn't found.  Any other number means that an instance
    " has been found.
    return search_result
endfunction

我该如何解决?谢谢大家。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)