- Use correct implementation of text_edits.
- Send indent options to rangeFormatting and formatting.
- Remove references to vim bindings and filetype from lsp.txt
- Add more examples to docs.
- Add before_init to allow changing initialize_params.
This commit is contained in:
Ashkan Kiani
2019-11-21 15:19:06 -08:00
parent 6a51401378
commit bcae04f6c6
5 changed files with 187 additions and 187 deletions

View File

@@ -261,11 +261,14 @@ end
function M.formatting(options)
validate { options = {options, 't', true} }
options = vim.tbl_extend('keep', options or {}, {
tabSize = api.nvim_buf_get_option(0, 'tabstop');
insertSpaces = api.nvim_buf_get_option(0, 'expandtab');
})
local params = {
textDocument = { uri = vim.uri_from_bufnr(0) };
options = options or {};
options = options;
}
params.options[vim.type_idx] = vim.types.dictionary
return request('textDocument/formatting', params, function(_, _, result)
if not result then return end
util.apply_text_edits(result)
@@ -278,6 +281,10 @@ function M.range_formatting(options, start_pos, end_pos)
start_pos = {start_pos, 't', true};
end_pos = {end_pos, 't', true};
}
options = vim.tbl_extend('keep', options or {}, {
tabSize = api.nvim_buf_get_option(0, 'tabstop');
insertSpaces = api.nvim_buf_get_option(0, 'expandtab');
})
start_pos = start_pos or vim.api.nvim_buf_get_mark(0, '<')
end_pos = end_pos or vim.api.nvim_buf_get_mark(0, '>')
local params = {
@@ -286,9 +293,8 @@ function M.range_formatting(options, start_pos, end_pos)
start = { line = start_pos[1]; character = start_pos[2]; };
["end"] = { line = end_pos[1]; character = end_pos[2]; };
};
options = options or {};
options = options;
}
params.options[vim.type_idx] = vim.types.dictionary
return request('textDocument/rangeFormatting', params, function(_, _, result)
if not result then return end
util.apply_text_edits(result)