-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement inlay virtual text for rust and go (#759)
* feat: implement inlay virtual text for rust and go Signed-off-by: 蔡略 <[email protected]> * fix: go-nvim use lsp-inlayhints.nvim only Signed-off-by: 蔡略 <[email protected]> * refactor: move inlay-hints to `completion` Signed-off-by: 蔡略 <[email protected]> * feat: lua support Signed-off-by: 蔡略 <[email protected]> * chore(inlay-hints): remove `sumneko_lua` * fix: set inlay-hints debug mode off Signed-off-by: 蔡略 <[email protected]> --------- Signed-off-by: 蔡略 <[email protected]> Co-authored-by: Charles Chiu <[email protected]>
- Loading branch information
1 parent
abaa7c5
commit b434c79
Showing
9 changed files
with
113 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
return function() | ||
-- listed below are the default values | ||
local override = { | ||
inlay_hints = { | ||
parameter_hints = { | ||
show = true, | ||
}, | ||
type_hints = { | ||
show = true, | ||
}, | ||
label_formatter = function(tbl, kind, opts, client_name) | ||
if kind == 2 and not opts.parameter_hints.show then | ||
return "" | ||
elseif not opts.type_hints.show then | ||
return "" | ||
end | ||
|
||
return table.concat(tbl, ", ") | ||
end, | ||
virt_text_formatter = function(label, hint, opts, client_name) | ||
if client_name == "lua_ls" then | ||
if hint.kind == 2 then | ||
hint.paddingLeft = false | ||
else | ||
hint.paddingRight = false | ||
end | ||
end | ||
|
||
local vt = {} | ||
vt[#vt + 1] = hint.paddingLeft and { " ", "None" } or nil | ||
vt[#vt + 1] = { label, opts.highlight } | ||
vt[#vt + 1] = hint.paddingRight and { " ", "None" } or nil | ||
|
||
return vt | ||
end, | ||
only_current_line = false, | ||
-- highlight group | ||
highlight = "LspInlayHint", | ||
-- highlight = "Comment", | ||
-- virt_text priority | ||
priority = 0, | ||
}, | ||
enabled_at_startup = true, | ||
debug_mode = false, | ||
} | ||
require("lsp-inlayhints").setup(override) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
return function() | ||
require("go").setup({ | ||
lsp_keymaps = false, | ||
dap_debug_keymap = false, | ||
icons = false, | ||
gofmt = "gopls", | ||
goimport = "gopls", | ||
lsp_gofumpt = "true", | ||
lsp_inlay_hints = { enable = false }, | ||
run_in_floaterm = true, | ||
trouble = true, | ||
lsp_cfg = { | ||
flags = { debounce_text_changes = 500 }, | ||
cmd = { "gopls", "-remote=auto" }, | ||
settings = { | ||
gopls = { | ||
usePlaceholders = true, | ||
analyses = { | ||
nilness = true, | ||
shadow = true, | ||
unusedparams = true, | ||
unusewrites = true, | ||
}, | ||
hints = { | ||
assignVariableTypes = true, | ||
compositeLiteralFields = true, | ||
constantValues = true, | ||
functionTypeParameters = true, | ||
parameterNames = true, | ||
rangeVariableTypes = true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters