Skip to content

Commit 286d247

Browse files
committed
some updates for 0.8, more to come
1 parent 695f01e commit 286d247

File tree

14 files changed

+89
-215
lines changed

14 files changed

+89
-215
lines changed

xdg_config/nvim/.gdb_history

Whitespace-only changes.

xdg_config/nvim/after/plugin/colorscheme.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ Group.new("TSTitle", c.blue)
5151
-- the text with characters or something like that...
5252
-- but we'll have to stick to that for later.
5353
Group.new("InjectedLanguage", nil, g.Normal.bg:dark())
54+
55+
Group.new("LspParameter", nil, nil, s.italic)
56+
Group.new("LspDeprecated", nil, nil, s.strikethrough)

xdg_config/nvim/after/plugin/comments.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ require("Comment").setup {
2626
-- extra mapping
2727
-- Includes `gco`, `gcO`, `gcA`
2828
extra = true,
29-
30-
-- extended mapping
31-
-- Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}`
32-
extended = true,
3329
},
3430

3531
-- LHS of toggle mapping in NORMAL + VISUAL mode

xdg_config/nvim/after/plugin/notify.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ if not pcall(require, "plenary") then
22
return
33
end
44

5+
if pcall(require, "noice") then
6+
return
7+
end
8+
59
local log = require("plenary.log").new {
610
plugin = "notify",
711
level = "debug",
@@ -10,6 +14,5 @@ local log = require("plenary.log").new {
1014

1115
vim.notify = function(msg, level, opts)
1216
log.info(msg, level, opts)
13-
1417
require "notify"(msg, level, opts)
1518
end

xdg_config/nvim/lua/tj/auto.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
local func = {}
2+
3+
func.autocmd = function(args)
4+
local event = args[1]
5+
local group = args[2]
6+
local callback = args[3]
7+
8+
vim.api.nvim_create_autocmd(event, {
9+
group = group,
10+
buffer = args[4],
11+
callback = function()
12+
callback()
13+
end,
14+
once = args.once,
15+
})
16+
end
17+
18+
return func

xdg_config/nvim/lua/tj/lsp/extensions.lua

Lines changed: 0 additions & 19 deletions
This file was deleted.

xdg_config/nvim/lua/tj/lsp/handlers.lua

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
local override = require "tj.lsp.override"
2-
31
-- Jump directly to the first available definition every time.
42
vim.lsp.handlers["textDocument/definition"] = function(_, result)
53
if not result or vim.tbl_isempty(result) then
@@ -80,13 +78,4 @@ vim.lsp.codelens.display = require("gl.codelens").display
8078
-- :run()
8179
-- end
8280

83-
-- override.set("workspace/executeCommand", function(err, result, ctx, config)
84-
-- if vim.bo[ctx.bufnr].filetype ~= "go" then
85-
-- return override.get(ctx.method)(err, result, ctx, config)
86-
-- end
87-
--
88-
-- print("filetype:", vim.bo[ctx.bufnr].filetype)
89-
-- P(ctx)
90-
-- end)
91-
9281
return M

xdg_config/nvim/lua/tj/lsp/init.lua

Lines changed: 47 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,34 @@
1+
local lspconfig = vim.F.npcall(require, "lspconfig")
2+
if not lspconfig then
3+
return
4+
end
5+
16
local imap = require("tj.keymap").imap
27
local nmap = require("tj.keymap").nmap
8+
local autocmd = require("tj.auto").autocmd
9+
local autocmd_clear = vim.api.nvim_clear_autocmds
310

4-
local has_lsp, lspconfig = pcall(require, "lspconfig")
5-
if not has_lsp then
6-
return
7-
end
11+
local semantic = vim.F.npcall(require, "nvim-semantic-tokens")
812

913
local is_mac = vim.fn.has "macunix" == 1
1014

1115
local lspconfig_util = require "lspconfig.util"
1216

13-
local ok, nvim_status = pcall(require, "lsp-status")
14-
if not ok then
15-
nvim_status = nil
16-
end
17-
1817
local telescope_mapper = require "tj.telescope.mappings"
1918
local handlers = require "tj.lsp.handlers"
2019

2120
local ts_util = require "nvim-lsp-ts-utils"
2221

23-
-- Can set this lower if needed.
24-
-- require("vim.lsp.log").set_level "debug"
25-
-- require("vim.lsp.log").set_level "trace"
26-
27-
local status = require "tj.lsp.status"
28-
if status then
29-
status.activate()
30-
end
31-
3222
local custom_init = function(client)
3323
client.config.flags = client.config.flags or {}
3424
client.config.flags.allow_incremental_sync = true
3525
end
3626

37-
local augroup_format = vim.api.nvim_create_augroup("my_lsp_format", { clear = true })
27+
local augroup_highlight = vim.api.nvim_create_augroup("custom-lsp-references", { clear = true })
28+
local augroup_codelens = vim.api.nvim_create_augroup("custom-lsp-codelens", { clear = true })
29+
local augroup_format = vim.api.nvim_create_augroup("custom-lsp-format", { clear = true })
30+
local augroup_semantic = vim.api.nvim_create_augroup("custom-lsp-semantic", { clear = true })
31+
3832
local autocmd_format = function(async, filter)
3933
vim.api.nvim_clear_autocmds { buffer = 0, group = augroup_format }
4034
vim.api.nvim_create_autocmd("BufWritePre", {
@@ -100,13 +94,9 @@ local buf_inoremap = function(opts)
10094
imap(opts)
10195
end
10296

103-
local custom_attach = function(client)
97+
local custom_attach = function(client, bufnr)
10498
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
10599

106-
if nvim_status then
107-
nvim_status.on_attach(client)
108-
end
109-
110100
buf_inoremap { "<c-s>", vim.lsp.buf.signature_help }
111101

112102
buf_nnoremap { "<space>cr", vim.lsp.buf.rename }
@@ -133,41 +123,48 @@ local custom_attach = function(client)
133123

134124
-- Set autocommands conditional on server_capabilities
135125
if client.server_capabilities.documentHighlightProvider then
136-
vim.cmd [[
137-
augroup lsp_document_highlight
138-
autocmd! * <buffer>
139-
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
140-
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
141-
augroup END
142-
]]
126+
autocmd_clear { group = augroup_highlight, buffer = bufnr }
127+
autocmd { "CursorHold", augroup_highlight, vim.lsp.buf.document_highlight, buffer = bufnr }
128+
autocmd { "CursorMoved", augroup_highlight, vim.lsp.buf.clear_references, buffer = bufnr }
143129
end
144130

145131
if false and client.server_capabilities.codeLensProvider then
146132
if filetype ~= "elm" then
147-
vim.cmd [[
148-
augroup lsp_document_codelens
149-
au! * <buffer>
150-
autocmd BufEnter ++once <buffer> lua require"vim.lsp.codelens".refresh()
151-
autocmd BufWritePost,CursorHold <buffer> lua require"vim.lsp.codelens".refresh()
152-
augroup END
153-
]]
133+
autocmd_clear { group = augroup_codelens, buffer = bufnr }
134+
autocmd { "BufEnter", augroup_codelens, vim.lsp.codelens.refresh, bufnr, once = true }
135+
autocmd { { "BufWritePost", "CursorHold" }, augroup_codelens, vim.lsp.codelens.refresh, bufnr }
154136
end
155137
end
156138

139+
local caps = client.server_capabilities
140+
if semantic and caps.semanticTokensProvider and caps.semanticTokensProvider.full then
141+
autocmd_clear { group = augroup_semantic, buffer = bufnr }
142+
autocmd { "TextChanged", augroup_semantic, vim.lsp.buf.semantic_tokens_full, bufnr }
143+
end
144+
157145
-- Attach any filetype specific options to the client
158146
filetype_attach[filetype](client)
159147
end
160148

161149
local updated_capabilities = vim.lsp.protocol.make_client_capabilities()
162-
if nvim_status then
163-
updated_capabilities = vim.tbl_deep_extend("keep", updated_capabilities, nvim_status.capabilities)
164-
end
165-
updated_capabilities.textDocument.codeLens = { dynamicRegistration = false }
166-
updated_capabilities = require("cmp_nvim_lsp").update_capabilities(updated_capabilities)
150+
151+
-- Completion configuration
152+
require("cmp_nvim_lsp").update_capabilities(updated_capabilities)
167153
updated_capabilities.textDocument.completion.completionItem.insertReplaceSupport = false
168154

169-
local rust_analyzer
155+
-- Semantic token configuration
156+
if semantic then
157+
semantic.setup {
158+
preset = "default",
159+
highlighters = { require "nvim-semantic-tokens.table-highlighter" },
160+
}
161+
162+
semantic.extend_capabilities(updated_capabilities)
163+
end
164+
165+
updated_capabilities.textDocument.codeLens = { dynamicRegistration = false }
170166

167+
local rust_analyzer, rust_analyzer_cmd = nil, { "rustup", "run", "nightly", "rust-analyzer" }
171168
local has_rt, rt = pcall(require, "rust-tools")
172169
if has_rt then
173170
local extension_path = vim.fn.expand "~/.vscode/extensions/sadge-vscode/extension/"
@@ -176,7 +173,7 @@ if has_rt then
176173

177174
rt.setup {
178175
server = {
179-
cmd = { "rustup", "run", "nightly", "rust-analyzer" },
176+
cmd = rust_analyzer_cmd,
180177
capabilities = updated_capabilities,
181178
on_attach = custom_attach,
182179
},
@@ -191,13 +188,11 @@ if has_rt then
191188
}
192189
else
193190
rust_analyzer = {
194-
cmd = { "rustup", "run", "nightly", "rust-analyzer" },
195-
-- cmd = { "rust-analyzer" },
191+
cmd = rust_analyzer_cmd,
196192
}
197193
end
198194

199195
local servers = {
200-
201196
-- Also uses `shellcheck` and `explainshell`
202197
bashls = true,
203198

@@ -220,11 +215,9 @@ local servers = {
220215
"--clang-tidy",
221216
"--header-insertion=iwyu",
222217
},
223-
-- Required for lsp-status
224218
init_options = {
225219
clangdFileStatus = true,
226220
},
227-
handlers = nvim_status and nvim_status.extensions.clangd.setup() or nil,
228221
},
229222

230223
gopls = {
@@ -423,25 +416,6 @@ end
423416
-- end
424417
--]]
425418

426-
-- python graveyard
427-
-- lspconfig.pyls.setup {
428-
-- plugins = {
429-
-- pyls_mypy = {
430-
-- enabled = true,
431-
-- live_mode = false
432-
-- }
433-
-- },
434-
-- on_init = custom_init,
435-
-- on_attach = custom_attach,
436-
-- capabilities = updated_capabilities,
437-
-- }
438-
439-
-- lspconfig.jedi_language_server.setup {
440-
-- on_init = custom_init,
441-
-- on_attach = custom_attach,
442-
-- capabilities = updated_capabilities,
443-
-- }
444-
445419
-- Set up null-ls
446420
local use_null = true
447421
if use_null then
@@ -456,6 +430,10 @@ if use_null then
456430
}
457431
end
458432

433+
-- Can set this lower if needed.
434+
-- require("vim.lsp.log").set_level "debug"
435+
-- require("vim.lsp.log").set_level "trace"
436+
459437
return {
460438
on_init = custom_init,
461439
on_attach = custom_attach,

xdg_config/nvim/lua/tj/lsp/override.lua

Lines changed: 0 additions & 22 deletions
This file was deleted.

xdg_config/nvim/lua/tj/lsp/status.lua

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)