@@ -3,168 +3,6 @@ vim.opt.tabstop = 8
33vim .opt .expandtab = false
44
55-- lsp
6- vim .lsp .start ({
7- name = " gopls" ,
8- cmd = { " gopls" },
9- filetypes = { " go" , " gomod" , " gowork" , " gotmpl" },
10- on_attach = function (client , bufnr )
11- -- explicitly enable and modify some semantic tokens
12- if not client .server_capabilities .semanticTokensProvider then
13- local semantic = client .config .capabilities .textDocument .semanticTokens
14- if semantic == nil then
15- return
16- end
17- client .server_capabilities .semanticTokensProvider = {
18- full = true ,
19- legend = {
20- tokenTypes = semantic .tokenTypes ,
21- tokenModifiers = semantic .tokenModifiers ,
22- },
23- range = true ,
24- }
25- end
26- vim .api .nvim_create_autocmd (" LspTokenUpdate" , {
27- callback = function (args )
28- local token = args .data .token
29- if token .type == " keyword" and not token .modifiers .readonly then
30- local keyword =
31- vim .api .nvim_buf_get_text (args .buf , token .line , token .start_col , token .line , token .end_col , {})[1 ]
32- if keyword == " return" or keyword == " package" or keyword == " import" or keyword == " go" then
33- vim .lsp .semantic_tokens .highlight_token (token , args .buf , args .data .client_id , " @keyword.return" )
34- end
35- end
36- end ,
37- })
38- end ,
39- root_dir = vim .fs .dirname (vim .fs .find ({ " go.mod" , " go.sum" , " .git/" }, { upward = true })[1 ]),
40- single_file_support = true ,
41- -- capabilities = vim.lsp.protocol.make_client_capabilities(),
42- capabilities = require (" blink.cmp" ).get_lsp_capabilities (vim .lsp .protocol .make_client_capabilities ()),
43- settings = {
44- gopls = {
45- -- Build: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#build
46- buildFlags = { " -tags=unit,integration,e2e" },
47- -- env = {},
48- directoryFilters = { " -.git" },
49- -- templateExtensions = {},
50- -- expandWorkspaceToModule = true,
51- -- standaloneTags = { "ignore" },
52- -- workspaceFiles = {},
53-
54- -- Formatting: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#formatting
55- -- local = "",
56- gofumpt = true ,
57- -- UI: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#ui
58- codelenses = { -- https://github.com/golang/tools/blob/master/gopls/doc/codelenses.md
59- -- generate = true,
60- -- regenerate_cgo = true,
61- test = true ,
62- -- run_govulncheck = false,
63- -- tidy = true,
64- -- upgrade_dependency = true,
65- -- vendor = true,
66- vulncheck = true ,
67- },
68- semanticTokens = true ,
69- -- noSemanticString = false,
70- -- noSemanticNumber = false,
71- -- semanticTokenTypes = {},
72- -- semanticTokenModifiers = {},
73-
74- -- Completion: https://github.com/golang/tools/blob/master/gopls/doc/codelenses.md
75- -- usePlaceholders = false,
76- -- experimentalPostfixCompletions = true,
77- -- completeFunctionCalls = true,
78-
79- -- Diagnostic: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#diagnostic
80- analyses = { -- https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
81- -- appends = true,
82- -- asmdecl = true,
83- -- assign = true,
84- -- atomic = true,
85- -- atomicalign = true,
86- -- bools = true,
87- -- buildtag = true,
88- -- cgocall = true,
89- -- composites = true,
90- -- copylocks = true,
91- -- deepequalerrors = true,
92- -- defers = true,
93- -- deprecated = true,
94- -- directive = true,
95- -- embed = true,
96- -- errorsas = true,
97- -- fillreturns = true,
98- -- framepointer = true,
99- -- gofix = true,
100- -- hostport = true,
101- -- httpresponse = true,
102- -- ifaceassert = true,
103- -- infertypeargs = true,
104- -- loopclosure = true,
105- -- lostcancel = true,
106- -- modernize = true,
107- -- nilfunc = true,
108- -- nilness = true,
109- -- nonewvars = true,
110- -- noresultvalues = true,
111- -- printf = true,
112- -- shadow = false, -- useful, but to spammy with `err`
113- -- shift = true,
114- -- sigchanyzer = true,
115- -- simplifycompositelit = true,
116- -- simplifyrange = true,
117- -- simplifyslice = true,
118- -- sortslice = true,
119- -- stdmethods = true,
120- -- stdversion = true,
121- -- stringintconv = true,
122- -- structag = true,
123- -- testinggoroutine = true,
124- -- tests = true,
125- -- timeformat = true,
126- -- unmarshal = true,
127- -- unreachable = true,
128- -- unsafeptr = true,
129- -- unusedfunc = true,
130- -- unusedparams = true,
131- -- unusedresult = true,
132- -- unusedvariable = true,
133- -- unusedwrite = true,
134- -- waitgroup = true,
135- -- yield = true,
136- },
137- staticcheck = true ,
138- vulncheck = " Imports" ,
139-
140- -- Documentations: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#documentation
141- -- hoverKind = "FullDocumentation",
142- -- linkTarget = "pkg.go.dev",
143- -- linksInHover = true, -- default
144- -- linksInHover = "gopls", -- this enables offline doc links
145-
146- -- Inlayhint: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#inlayhint
147- hints = { -- https://github.com/golang/tools/blob/master/gopls/doc/inlayHints.md
148- assignVariableTypes = true ,
149- compositeLiteralFields = true ,
150- compositeLiteralTypes = true ,
151- constantValues = true ,
152- functionTypeParameters = true ,
153- parameterNames = true ,
154- rangeVariableTypes = true ,
155- },
156-
157- -- Navigation: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#navigation
158- -- importShortcut = "Both",
159- -- symbolScope = "all",
160-
161- -- Internal
162- completeUnimported = true ,
163- deepCompletion = true ,
164- },
165- },
166- })
167-
1686vim .api .nvim_create_autocmd (" LspAttach" , {
1697 group = vim .api .nvim_create_augroup (" lsp_user_bindings_gopls" , {}),
1708 callback = function (event )
@@ -256,5 +94,3 @@ vim.keymap.set("n", "gY", function()
25694 else
25795 end
25896end , { desc = " copy test command" })
259-
260- pcall (vim .cmd , " TSContextEnable" )
0 commit comments