All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 let s:fixendofline_exists = exists('+fixendofline')
3 function! s:get_fixendofline(buf) abort
4 let l:eol = getbufvar(a:buf, '&endofline')
5 let l:binary = getbufvar(a:buf, '&binary')
7 if s:fixendofline_exists
8 let l:fixeol = getbufvar(a:buf, '&fixendofline')
11 " When 'binary' is off and 'fixeol' is on, 'endofline' is not used
13 " When 'binary' is off and 'fixeol' is off, 'endofline' is used to
14 " remember the presence of a <EOL>
15 return l:fixeol || l:eol
17 " When 'binary' is on, the value of 'fixeol' doesn't matter
21 " When 'binary' is off the value of 'endofline' is not used
23 " When 'binary' is on 'endofline' is used to remember the presence of
25 return !l:binary || l:eol
29 function! lsp#utils#buffer#_get_fixendofline(bufnr) abort
30 return s:get_fixendofline(a:bufnr)
33 function! lsp#utils#buffer#_get_lines(buf) abort
34 let l:lines = getbufline(a:buf, 1, '$')
35 if s:get_fixendofline(a:buf)
41 " @params {location} = {
42 " 'uri': 'file://....',
44 " 'start': { 'line': 1, 'character': 1 },
45 " 'end': { 'line': 1, 'character': 1 },
48 function! lsp#utils#buffer#_open_lsp_location(location) abort
49 let l:path = lsp#utils#uri_to_path(a:location['uri'])
50 let l:bufnr = bufnr(l:path)
52 let [l:start_line, l:start_col] = lsp#utils#position#lsp_to_vim(l:bufnr, a:location['range']['start'])
53 let [l:end_line, l:end_col] = lsp#utils#position#lsp_to_vim(l:bufnr, a:location['range']['end'])
56 if &modified && !&hidden
57 let l:cmd = l:bufnr !=# -1 ? 'sb ' . l:bufnr : 'split ' . fnameescape(l:path)
59 let l:cmd = l:bufnr !=# -1 ? 'b ' . l:bufnr : 'edit ' . fnameescape(l:path)
61 execute l:cmd . ' | call cursor('.l:start_line.','.l:start_col.')'
64 call setpos("'<", [l:bufnr, l:start_line, l:start_col])
65 call setpos("'>", [l:bufnr, l:end_line, l:end_col])
68 function! lsp#utils#buffer#get_indent_size(bufnr) abort
69 let l:shiftwidth = getbufvar(a:bufnr, '&shiftwidth')
70 if getbufvar(a:bufnr, '&shiftwidth')
73 return getbufvar(a:bufnr, '&tabstop')