diff options
author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-06-27 11:27:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-27 11:27:51 +0900 |
commit | 7efb302d26abd863e2cbbf4d2d6f7bb4aa31cc29 (patch) | |
tree | 249ccd0759e4d61bdaea99f27e4e1c4ae965bbdc /runtime/lua/vim/lsp/buf.lua | |
parent | 225f0bcd98dd8ff8cab964f13816dfdf327038ae (diff) | |
parent | ebee9ebe2be2bd584efefc4064a8b3a07e0505e0 (diff) | |
download | rneovim-7efb302d26abd863e2cbbf4d2d6f7bb4aa31cc29.tar.gz rneovim-7efb302d26abd863e2cbbf4d2d6f7bb4aa31cc29.tar.bz2 rneovim-7efb302d26abd863e2cbbf4d2d6f7bb4aa31cc29.zip |
Merge pull request #12252 from dlukes/formatting-sync
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 7a819f3c3d..81d78c8b98 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -65,19 +65,18 @@ function M.completion(context) end function M.formatting(options) - validate { options = {options, 't', true} } - local sts = vim.bo.softtabstop; - options = vim.tbl_extend('keep', options or {}, { - tabSize = (sts > 0 and sts) or (sts < 0 and vim.bo.shiftwidth) or vim.bo.tabstop; - insertSpaces = vim.bo.expandtab; - }) - local params = { - textDocument = { uri = vim.uri_from_bufnr(0) }; - options = options; - } + local params = util.make_formatting_params(options) return request('textDocument/formatting', params) end +function M.formatting_sync(options, timeout_ms) + local params = util.make_formatting_params(options) + local result = vim.lsp.buf_request_sync(0, "textDocument/formatting", params, timeout_ms) + if not result then return end + result = result[1].result + vim.lsp.util.apply_text_edits(result) +end + function M.range_formatting(options, start_pos, end_pos) validate { options = {options, 't', true}; |