mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
Merge pull request #12252 from dlukes/formatting-sync
This commit is contained in:
@@ -1260,6 +1260,30 @@ function M.make_text_document_params()
|
||||
return { uri = vim.uri_from_bufnr(0) }
|
||||
end
|
||||
|
||||
--- Get visual width of tabstop.
|
||||
---
|
||||
--@see |softtabstop|
|
||||
--@param bufnr (optional, number): Buffer handle, defaults to current
|
||||
--@returns (number) tabstop visual width
|
||||
function M.get_effective_tabstop(bufnr)
|
||||
validate { bufnr = {bufnr, 'n', true} }
|
||||
local bo = bufnr and vim.bo[bufnr] or vim.bo
|
||||
local sts = bo.softtabstop
|
||||
return (sts > 0 and sts) or (sts < 0 and bo.shiftwidth) or bo.tabstop
|
||||
end
|
||||
|
||||
function M.make_formatting_params(options)
|
||||
validate { options = {options, 't', true} }
|
||||
options = vim.tbl_extend('keep', options or {}, {
|
||||
tabSize = M.get_effective_tabstop();
|
||||
insertSpaces = vim.bo.expandtab;
|
||||
})
|
||||
return {
|
||||
textDocument = { uri = vim.uri_from_bufnr(0) };
|
||||
options = options;
|
||||
}
|
||||
end
|
||||
|
||||
-- @param buf buffer handle or 0 for current.
|
||||
-- @param row 0-indexed line
|
||||
-- @param col 0-indexed byte offset in line
|
||||
|
Reference in New Issue
Block a user