forked from Exafunction/windsurf.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.vim
More file actions
122 lines (116 loc) · 3.18 KB
/
doc.vim
File metadata and controls
122 lines (116 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
let s:language_enum = {
\ 'unspecified': 0,
\ 'c': 1,
\ 'clojure': 2,
\ 'coffeescript': 3,
\ 'cpp': 4,
\ 'csharp': 5,
\ 'css': 6,
\ 'cudacpp': 7,
\ 'dockerfile': 8,
\ 'go': 9,
\ 'groovy': 10,
\ 'handlebars': 11,
\ 'haskell': 12,
\ 'hcl': 13,
\ 'html': 14,
\ 'ini': 15,
\ 'java': 16,
\ 'javascript': 17,
\ 'json': 18,
\ 'julia': 19,
\ 'kotlin': 20,
\ 'latex': 21,
\ 'tex': 21,
\ 'less': 22,
\ 'lua': 23,
\ 'makefile': 24,
\ 'markdown': 25,
\ 'objectivec': 26,
\ 'objectivecpp': 27,
\ 'perl': 28,
\ 'php': 29,
\ 'plaintext': 30,
\ 'protobuf': 31,
\ 'pbtxt': 32,
\ 'python': 33,
\ 'r': 34,
\ 'ruby': 35,
\ 'rust': 36,
\ 'sass': 37,
\ 'scala': 38,
\ 'scss': 39,
\ 'shell': 40,
\ 'sql': 41,
\ 'starlark': 42,
\ 'swift': 43,
\ 'typescriptreact': 44,
\ 'typescript': 45,
\ 'visualbasic': 46,
\ 'vue': 47,
\ 'xml': 48,
\ 'xsl': 49,
\ 'yaml': 50,
\ 'svelte': 51,
\ 'toml': 52,
\ 'dart': 53,
\ 'rst': 54,
\ 'ocaml': 55,
\ 'cmake': 56,
\ 'pascal': 57,
\ 'elixir': 58,
\ 'fsharp': 59,
\ 'lisp': 60,
\ 'matlab': 61,
\ 'ps1': 62,
\ 'solidity': 63,
\ 'ada': 64,
\ 'blade': 84,
\ 'astro': 85,
\ }
let s:filetype_aliases = {
\ 'bash': 'shell',
\ 'coffee': 'coffeescript',
\ 'cs': 'csharp',
\ 'cuda': 'cudacpp',
\ 'dosini': 'ini',
\ 'javascriptreact': 'javascript',
\ 'make': 'makefile',
\ 'objc': 'objectivec',
\ 'objcpp': 'objectivecpp',
\ 'proto': 'protobuf',
\ 'raku': 'perl',
\ 'sh': 'shell',
\ 'text': 'plaintext',
\ }
function! codeium#doc#GetDocument(bufId, curLine, curCol) abort
let lines = getbufline(a:bufId, 1, '$')
if getbufvar(a:bufId, '&endofline')
call add(lines, '')
endif
let filetype = substitute(getbufvar(a:bufId, '&filetype'), '\..*', '', '')
let language = get(s:filetype_aliases, empty(filetype) ? 'text' : filetype, filetype)
if empty(filetype) && get(g:, 'codeium_warn_filetype_missing', v:true)
call codeium#log#Warn('No filetype detected. This will affect completion quality.')
let g:codeium_warn_filetype_missing = v:false
endif
let editor_language = empty(getbufvar(a:bufId, '&filetype')) ? 'unspecified' : getbufvar(a:bufId, '&filetype')
let doc = {
\ 'text': join(lines, codeium#util#LineEndingChars()),
\ 'editor_language': editor_language,
\ 'language': get(s:language_enum, language, 0),
\ 'cursor_position': {'row': a:curLine - 1, 'col': a:curCol - 1},
\ 'absolute_path_migrate_me_to_uri': fnamemodify(bufname(a:bufId), ':p'),
\ }
let line_ending = codeium#util#LineEndingChars(v:null)
if line_ending isnot# v:null
let doc.line_ending = line_ending
endif
return doc
endfunction
function! codeium#doc#GetEditorOptions() abort
return {
\ 'tab_size': shiftwidth(),
\ 'insert_spaces': &expandtab ? v:true : v:false,
\ }
endfunction