-
-
Notifications
You must be signed in to change notification settings - Fork 64
Add format debounce and improve debounce time setup #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please rebase master branch |
|
||
"github.com/sourcegraph/jsonrpc2" | ||
) | ||
|
||
func (h *langHandler) handleTextDocumentFormatting(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { | ||
func (h *langHandler) handleTextDocumentFormatting( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't prefer this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was reverted.
Really? |
Hi, Matt |
I think that Duration is not needed. |
The change to Duration is necessary
|
go-yaml seems to be already support time.Duration. |
I did not test yaml setup for efm-languageserver |
Could you please show me your neovim configuration for the efm-langserver? |
lspconfig.efm.setup {
flags = {debounce_text_changes = 1000},
cmd = {'efm-langserver', '-loglevel', '2', '-logfile', '/tmp/efm.log'},
init_options = {documentFormatting = true},
on_attach = function(client)
client.resolved_capabilities.document_formatting = true
client.resolved_capabilities.goto_definition = false
client.resolved_capabilities.code_action = nil
vim.cmd([[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting()]])
end,
filetypes = {
"javascript", "javascriptreact", 'typescript', 'typescriptreact',
'html', 'css', 'go', 'lua'
},
settings = {
rootMarkers = {".git/", 'package.json', 'Makefile', 'go.mod'},
lintDebounce = "2s",
formatDebounce = "1000ms",
languages = {
typescript = {stylelint, prettier},
typescriptreact = {stylelint, prettier},
javascript = {eslint_d},
javascriptreact = {eslint_d},
python = { python-flake8 },
go = {
{
formatCommand = "golines --max-len=120 --base-formatter=gofumpt",
formatStdin = true,
-- "staticcheck" ?
lintCommand = "golangci-lint run",
LintSeverity = 3,
}
},
lua = {
{ formatCommand = "lua-format --indent-width 2 --tab-width 2 --no-use-tab --column-limit 120 --column-table-limit 100 --no-keep-simple-function-one-line --no-chop-down-table --chop-down-kv-table --no-keep-simple-control-block-one-line --no-keep-simple-function-one-line --no-break-after-functioncall-lp --no-break-after-operator",
formatStdin = true,
}
},
}
}
}
|
Your
As far as I can see, it should work correctly. |
In fact, I am seeing an error in that file (with the config I post earlier):
|
Please take a look at golang/go#10275 |
Now I understood what is wrong. Thank you. |
Thank you |
Cheers! |
Hmm, this break compatibility. Now efm-langserver can not load yaml configuration. |
What is the config.yaml setting breaks the loading? |
In previous version, efm-langserver does not parse below.
Fixed in #147 |
In fact. I think that part is missing in the config.yaml. Could you also update the document of how to setup lint-debounce/format-debouce in default config.yaml |
The PR
Trying to improve the lintDebounce setup. Currently it only accepts int and it likely to mistake the time unit to ms. The golang Duration unit is ns. That means the setup need to use 500000000 to debounce 500ms. I did a quick grep of setups (dotfiles) in github. Most people are setting this field to 500, I believe they mean to set up debounce to 500ms. The changes allow user setup the debounce to "500ms" or "0.5s".
Add format debounce. I saw random failures when multiple format tools were configured and will trigger lsp format multiple times. This sometime result in an incorrect result.