Skip to content
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

Go Comment can be colorful #505

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,6 @@ require('go').setup({
tag_options = 'json=omitempty', -- sets options sent to gomodifytags, i.e., json=omitempty
gotests_template = "", -- sets gotests -template parameter (check gotests for details)
gotests_template_dir = "", -- sets gotests -template_dir parameter (check gotests for details)
comment_placeholder = '' , -- comment_placeholder your cool placeholder e.g. 󰟓    
icons = {breakpoint = '🧘', currentpos = '🏃'}, -- setup to `false` to disable icons setup
verbose = false, -- output loginf in messages
lsp_cfg = false, -- true: use non-default gopls setup specified in go/lsp.lua
Expand Down Expand Up @@ -874,6 +873,18 @@ require('go').setup({
on_stderr = function(err, data) _, _ = err, data end, -- callback for stderr
on_exit = function(code, signal, output) _, _, _ = code, signal, output end, -- callback for jobexit, output : string
iferr_vertical_shift = 4 -- defines where the cursor will end up vertically from the begining of if err statement
comment = {
placeholder = '' , -- comment_placeholder your cool placeholder e.g. 󰟓    
queries = nil -- set to a table of queries to use for comment highlight see comment.lua
highlight_groups = { -- default comment highlight groups, see comment.lua
-- redefine or set back to Comment to disable
-- types = 'GoCommentType',
-- functions = 'GoCommentFunction',
-- variables = 'GoCommentVariable',
-- constants = 'GoCommentConstant',
-- parameters = 'GoCommentParameter',
}
}
})
```

Expand Down
7 changes: 6 additions & 1 deletion doc/go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ You can setup go.nvim with following options:
max_line_len = 120,
tag_transform = false,
test_dir = "",
comment_placeholder = "  ",
icons = { breakpoint = "🧘", currentpos = "🏃" }, -- set to false to disable
-- this option
verbose = false,
Expand Down Expand Up @@ -458,6 +457,12 @@ You can setup go.nvim with following options:
run_in_floaterm = false, -- set to true to run in float window.
luasnip = false, -- set true to enable included luasnip
iferr_vertical_shift = 4 -- defines where the cursor will end up vertically from the begining of if err statement after GoIfErr command
comment = {
placeholder = '  ',
enable_highlight = true, -- set to false to disable
queries = nil, -- set to a table of queries to use for comment highlight see comment.lua
highlight_groups = nil
}
}

vim:tw=78:ts=8:sts=8:sw=8:ft=help:norl:expandtab
16 changes: 14 additions & 2 deletions lua/go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ _GO_NVIM_CFG = {
gotests_template = '', -- sets gotests -template parameter (check gotests for details)
gotests_template_dir = '', -- sets gotests -template_dir parameter (check gotests for details)

comment_placeholder = '  ',
icons = { breakpoint = '🧘', currentpos = '🏃' }, -- set to false to disable icons setup
sign_priority = 7, -- set priority of signs used by go.nevim
verbose = false,
Expand Down Expand Up @@ -81,9 +80,11 @@ _GO_NVIM_CFG = {
-- so you will run `watchexe --restart -v -e go go run `
end,
},
-- deprecated setups for nvim version < 0.10
lsp_inlay_hints = {
enable = true,

-- deprecated setups for nvim version < 0.10

style = 'inlay', -- 'default: inlay', 'eol': show at end of line, 'inlay': show in the middle of the line

-- Note: following setup only for for style == 'eol'
Expand Down Expand Up @@ -175,6 +176,12 @@ _GO_NVIM_CFG = {
_, _, _ = code, signal, output
end, -- callback for jobexit, output : string
iferr_vertical_shift = 4, -- defines where the cursor will end up vertically from the begining of if err statement after GoIfErr command
comment = {
placeholder = '  ',
enable_highlight = false, -- set to true to disable
queries = nil, -- set to a table of queries to use for comment highlight see comment.lua
highlight_groups = nil
}
}

-- TODO: nvim_{add,del}_user_command https://github.com/neovim/neovim/pull/16752
Expand Down Expand Up @@ -216,6 +223,10 @@ function go.setup(cfg)
vim.log.levels.WARN
)
end
if cfg.comment_placeholder ~= nil then
vim.notify('go.nvim comment_placeholder deprecated, use comment.placeholder', vim.log.levels.WARN)
cfg.comment.placeholder = cfg.comment_placeholder
end
if cfg.goimport ~= nil then
vim.notify('go.nvim goimport deprecated, use goimports', vim.log.levels.WARN)
cfg.goimports = cfg.goimport
Expand Down Expand Up @@ -248,6 +259,7 @@ function go.setup(cfg)
vim.defer_fn(function()
require('go.project').load_project()
require('go.utils').set_nulls()
require('go.comment')
end, 1)

if _GO_NVIM_CFG.run_in_floaterm then
Expand Down
Loading
Loading