Skip to content

Commit

Permalink
feat(api): use latest node client
Browse files Browse the repository at this point in the history
Remove src/neovim folder.

getOption() return true and false for boolean option on vim (same as
neovim), instead of 0 and 1.
  • Loading branch information
chemzqm committed Feb 23, 2025
1 parent a688482 commit eddf775
Show file tree
Hide file tree
Showing 192 changed files with 306 additions and 3,198 deletions.
67 changes: 67 additions & 0 deletions autoload/coc/api.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ let s:buffer_id = {}
let s:id_types = {}
let s:tab_id = 1
let s:keymap_arguments = ['nowait', 'silent', 'script', 'expr', 'unique']
" Boolean options of vim 9.1.1134
let s:boolean_options = ['allowrevins', 'arabic', 'arabicshape', 'autochdir', 'autoindent', 'autoread', 'autoshelldir', 'autowrite', 'autowriteall', 'backup', 'balloonevalterm', 'binary', 'bomb', 'breakindent', 'buflisted', 'cdhome', 'cindent', 'compatible', 'confirm', 'copyindent', 'cursorbind', 'cursorcolumn', 'cursorline', 'delcombine', 'diff', 'digraph', 'edcompatible', 'emoji', 'endoffile', 'endofline', 'equalalways', 'errorbells', 'esckeys', 'expandtab', 'exrc', 'fileignorecase', 'fixendofline', 'foldenable', 'fsync', 'gdefault', 'hidden', 'hkmap', 'hkmapp', 'hlsearch', 'icon', 'ignorecase', 'imcmdline', 'imdisable', 'incsearch', 'infercase', 'insertmode', 'joinspaces', 'langnoremap', 'langremap', 'lazyredraw', 'linebreak', 'lisp', 'list', 'loadplugins', 'magic', 'modeline', 'modelineexpr', 'modifiable', 'modified', 'more', 'number', 'paste', 'preserveindent', 'previewwindow', 'prompt', 'readonly', 'relativenumber', 'remap', 'revins', 'rightleft', 'ruler', 'scrollbind', 'secure', 'shelltemp', 'shiftround', 'shortname', 'showcmd', 'showfulltag', 'showmatch', 'showmode', 'smartcase', 'smartindent', 'smarttab', 'smoothscroll', 'spell', 'splitbelow', 'splitright', 'startofline', 'swapfile', 'tagbsearch', 'tagrelative', 'tagstack', 'termbidi', 'termguicolors', 'terse', 'textauto', 'textmode', 'tildeop', 'timeout', 'title', 'ttimeout', 'ttybuiltin', 'ttyfast', 'undofile', 'visualbell', 'warn', 'weirdinvert', 'wildignorecase', 'wildmenu', 'winfixbuf', 'winfixheight', 'winfixwidth', 'wrap', 'wrapscan', 'write', 'writeany', 'writebackup', 'xtermcodes']

" helper {{
" Create a window with bufnr for execute win_execute
Expand Down Expand Up @@ -433,6 +435,71 @@ function! s:funcs.del_keymap(mode, lhs) abort
execute 'silent '.a:mode.'unmap '.lhs
return v:null
endfunction

function! s:funcs.set_option_value(name, value, opts) abort
let l:win = get(a:opts, 'win', 0)
let l:buf = get(a:opts, 'buf', 0)
if has_key(a:opts, 'scope') && has_key(a:opts, 'buf')
throw "Can't use both scope and buf"
endif
let l:scope = get(a:opts, 'scope', 'global')
call s:check_option_args(l:scope, l:win, l:buf)
if l:buf != 0
call s:funcs.buf_set_option(l:buf, a:name, a:value)
elseif l:win != 0
call s:funcs.win_set_option(l:win, a:name, a:value)
else
if l:scope ==# 'global'
execute 'let &'.a:name.' = a:value'
else
call s:funcs.win_set_option(win_getid(), a:name, a:value)
call s:funcs.buf_set_option(bufnr('%'), a:name, a:value)
endif
endif
return v:null
endfunction

function! s:funcs.get_option_value(name, opts) abort
let l:win = get(a:opts, 'win', 0)
let l:buf = get(a:opts, 'buf', 0)
if has_key(a:opts, 'scope') && has_key(a:opts, 'buf')
throw "Can't use both scope and buf"
endif
let l:scope = get(a:opts, 'scope', 'global')
call s:check_option_args(l:scope, l:win, l:buf)
let l:result = v:null
" return eval('&'.a:name)
if l:buf != 0
let l:result = getbufvar(l:buf, '&'.a:name)
elseif l:win != 0
let l:result = s:funcs.win_get_option(l:win, a:name)
else
if l:scope ==# 'global'
let l:result = eval('&'.a:name)
else
let l:result = gettabwinvar(tabpagenr(), 0, '&'.a:name, get(a:, 1, v:null))
if l:result is v:null
let l:result = getbufvar(bufnr('%'), '&'.a:name)
endif
endif
endif
if index(s:boolean_options, a:name) != -1
return l:result == 0 ? v:false : v:true
endif
return l:result
endfunction

function! s:check_option_args(scope, win, buf) abort
if a:scope !=# 'global' && a:scope !=# 'local'
throw "Invalid 'scope': expected 'local' or 'global'"
endif
if a:win && empty(getwininfo(a:win)) && empty(popup_getpos(a:win))
throw "Invalid window id: ".a:win
endif
if a:buf && !bufexists(a:buf)
throw "Invalid buffer id: ".a:buf
endif
endfunction
" }}

" buffer methods {{
Expand Down
1 change: 1 addition & 0 deletions history.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Notable changes of coc.nvim:
## 2025-02-23

- All global properties works with extensions #5222.
- Return true or false for boolean option on vim (same as neovim).

## 2025-02-22

Expand Down
18 changes: 12 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"vscode-languageserver": "^9.0.1"
},
"dependencies": {
"@chemzqm/msgpack-lite": "^0.1.29",
"@chemzqm/neovim": "^6.1.7",
"ansi-styles": "^5.2.0",
"bytes": "^3.1.2",
"cli-table": "^0.3.11",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client/diagnostics.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import os from 'os'
import path from 'path'
import { v4 as uuid } from 'uuid'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client/progressPart.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Emitter, Event, NotificationHandler, WorkDoneProgressBegin, WorkDoneProgressEnd, WorkDoneProgressReport } from 'vscode-languageserver-protocol'
import { ProgressContext, ProgressPart } from '../../language-client/progressPart'
import helper from '../helper'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client/textSynchronization.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import fs from 'fs'
import os from 'os'
import path from 'path'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/completion/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, Disposable, Position, TextEdit } from 'vscode-languageserver-protocol'
import commands from '../../commands'
import completion, { Completion } from '../../completion'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/completion/float.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import Floating from '../../completion/floating'
import { getInsertWord, prefixWord } from '../../completion/pum'
import sources from '../../completion/sources'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/completion/language.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, Disposable } from 'vscode-languageserver-protocol'
import { CompletionItem, CompletionItemKind, CompletionList, InsertReplaceEdit, InsertTextFormat, InsertTextMode, Position, Range, TextEdit } from 'vscode-languageserver-types'
import commandManager from '../../commands'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/completion/sources.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import path from 'path'
import os from 'os'
import fs from 'fs'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/completion/util.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, CompletionItem, CompletionItemKind, CompletionItemTag, Disposable, InsertTextFormat, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import { caseScore, matchScore, matchScoreWithPositions } from '../../completion/match'
import sources from '../../completion/sources'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/autocmds.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, Emitter } from 'vscode-languageserver-protocol'
import { URI } from 'vscode-uri'
import { createCommand, getAutoCmdText } from '../../core/autocmds'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/documents.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import fs from 'fs'
import os from 'os'
import path from 'path'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/editors.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import Editors, { TextEditor, renamed } from '../../core/editors'
import workspace from '../../workspace'
import window from '../../window'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/files.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer, Neovim } from '../../neovim'
import { Buffer, Neovim } from '@chemzqm/neovim'
import fs from 'fs'
import os from 'os'
import path from 'path'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/keymaps.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import workspace from '../../workspace'
import Keymaps, { getBufnr, getKeymapModifier } from '../../core/keymaps'
import helper from '../helper'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/locations.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import os from 'os'
import path from 'path'
import { Location, Position, Range } from 'vscode-languageserver-protocol'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/terminals.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import os from 'os'
import path from 'path'
import which from 'which'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/ui.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Position, Range } from 'vscode-languageserver-types'
import * as ui from '../../core/ui'
import helper from '../helper'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/core/workspaceFolder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import fs from 'fs'
import os from 'os'
import path from 'path'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/callHierarchy.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, CallHierarchyItem, SymbolKind, Range, SymbolTag, CancellationToken, Position } from 'vscode-languageserver-protocol'
import CallHierarchyHandler from '../../handler/callHierarchy'
import languages from '../../languages'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/codeActions.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, CodeAction, CodeActionContext, CodeActionKind, Command, Disposable, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import { TextDocument } from 'vscode-languageserver-textdocument'
import commands from '../../commands'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/codelens.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, CodeLens, Command, Disposable, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import commands from '../../commands'
import events from '../../events'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable } from 'vscode-languageserver-protocol'
import commandManager from '../../commands'
import CommandsHandler from '../../handler/commands'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/documentColors.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, Color, ColorInformation, ColorPresentation, Disposable, Position, Range } from 'vscode-languageserver-protocol'
import { TextDocument } from 'vscode-languageserver-textdocument'
import commands from '../../commands'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/documentLinks.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, Disposable, DocumentLink, Range } from 'vscode-languageserver-protocol'
import { TextDocument } from 'vscode-languageserver-textdocument'
import events from '../../events'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/fold.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, CancellationTokenSource, Disposable, FoldingRange } from 'vscode-languageserver-protocol'
import FoldHandler from '../../handler/fold'
import languages from '../../languages'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/format.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, CancellationTokenSource, Disposable, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import commands from '../../commands'
import Format from '../../handler/format'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/highlights.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, DocumentHighlightKind, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import commands from '../../commands'
import Highlights from '../../handler/highlights'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/hover.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, MarkedString, Hover, Range, TextEdit, Position, CancellationToken, MarkupKind } from 'vscode-languageserver-protocol'
import HoverHandler, { addDefinitions, addDocument, isDocumentation, readLines } from '../../handler/hover'
import { URI } from 'vscode-uri'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, SymbolKind } from 'vscode-languageserver-protocol'
import commands from '../../commands'
import Handler from '../../handler/index'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/inlayHint.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationTokenSource, Disposable, InlayHint, InlayHintKind, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import commands from '../../commands'
import InlayHintHandler from '../../handler/inlayHint/index'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/inlineValue.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, Disposable, InlineValueText, Range } from 'vscode-languageserver-protocol'
import languages, { ProviderName } from '../../languages'
import { disposeAll } from '../../util'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/linkedEditing.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import LinkedEditingHandler from '../../handler/linkedEditing'
import languages from '../../languages'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/locations.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, LocationLink, Location, Range, Position, CancellationTokenSource, CancellationToken } from 'vscode-languageserver-protocol'
import LocationHandler from '../../handler/locations'
import languages from '../../languages'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/outline.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer, Neovim } from '../../neovim'
import { Buffer, Neovim } from '@chemzqm/neovim'
import { CodeAction, CodeActionKind, Disposable, DocumentSymbol, Range, SymbolKind, SymbolTag, TextEdit } from 'vscode-languageserver-protocol'
import events from '../../events'
import Symbols from '../../handler/symbols/index'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/refactor.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import fs from 'fs'
import { Position, Range, TextDocumentEdit, TextEdit, WorkspaceEdit } from 'vscode-languageserver-types'
import { URI } from 'vscode-uri'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/rename.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, Disposable, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import { TextDocument } from 'vscode-languageserver-textdocument'
import commands from '../../commands'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/search.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import Refactor from '../../handler/refactor'
import Search, { getPathFromArgs } from '../../handler/refactor/search'
import helper from '../helper'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/selectionRange.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Neovim } from '../../neovim'
import { Neovim } from '@chemzqm/neovim'
import { CancellationToken, Disposable, Position, Range, TextEdit } from 'vscode-languageserver-protocol'
import SelectionRange from '../../handler/selectionRange'
import languages from '../../languages'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/semanticTokens.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer, Neovim } from '@chemzqm/neovim'
import fs from 'fs'
import { tmpdir } from 'os'
import path from 'path'
Expand All @@ -8,7 +9,6 @@ import events from '../../events'
import SemanticTokensBuffer, { toHighlightPart } from '../../handler/semanticTokens/buffer'
import SemanticTokens from '../../handler/semanticTokens/index'
import languages from '../../languages'
import { Buffer, Neovim } from '../../neovim'
import { disposeAll } from '../../util'
import { CancellationError } from '../../util/errors'
import window from '../../window'
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/handler/signature.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Neovim } from '../../neovim'
import { Disposable, ParameterInformation, Range, SignatureInformation } from 'vscode-languageserver-protocol'
import { Neovim } from '@chemzqm/neovim'
import { Disposable, ParameterInformation, SignatureInformation, Range } from 'vscode-languageserver-protocol'
import commands from '../../commands'
import Signature from '../../handler/signature'
import languages from '../../languages'
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/handler/symbols.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer, Neovim } from '../../neovim'
import { Buffer, Neovim } from '@chemzqm/neovim'
import { CancellationToken, Disposable, Range, SymbolInformation, SymbolKind } from 'vscode-languageserver-protocol'
import events from '../../events'
import Symbols from '../../handler/symbols/index'
Expand Down
Loading

0 comments on commit eddf775

Please sign in to comment.