Skip to content

Commit 7e25e4a

Browse files
committed
nvim: update all the things
1 parent dff22f2 commit 7e25e4a

File tree

15 files changed

+757
-900
lines changed

15 files changed

+757
-900
lines changed

home/default.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,13 @@
121121
ast-grep
122122
buf
123123
codespell
124+
kulala-fmt
124125
nodePackages_latest.prettier
125126
proselint
126127
stylua
127128
tree-sitter
129+
typos
130+
typos-lsp
128131
vale
129132
yamllint
130133
# dev debug

home/nvim/default.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
};
2323
in {
2424
"nvim/init.lua".source = ./init.lua;
25-
"nvim/lua".source = ./lua;
26-
# "nvim/lua".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/home/nvim/lua";
27-
"nvim/ftplugin".source = ./ftplugin;
28-
# "nvim/ftplugin".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/home/nvim/ftplugin";
25+
# "nvim/lua".source = ./lua;
26+
"nvim/lua".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/home/nvim/lua";
27+
# "nvim/ftplugin".source = ./ftplugin;
28+
"nvim/ftplugin".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/home/nvim/ftplugin";
2929
"nvim/parser".source = "${treesitterParsers}/parser";
3030
"nvim/after/queries/go/textobjects.scm".source = ./go-textobjects.scm;
3131
"nvim/after/queries/gotmpl/injections.scm".source = ./gotmpl-injections.scm;
@@ -38,12 +38,14 @@
3838
"diffview-nvim"
3939
"friendly-snippets"
4040
"kanagawa-nvim"
41+
"kulala-nvim"
4142
"lazy-nvim"
4243
"lazydev-nvim"
4344
"noice-nvim"
4445
"nui-nvim"
4546
"nvim-bqf"
4647
"nvim-dap"
48+
# "nvim-dap-view"
4749
"nvim-impairative"
4850
"nvim-lint"
4951
"nvim-tree-lua"

home/nvim/ftplugin/go.lua

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -3,168 +3,6 @@ vim.opt.tabstop = 8
33
vim.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-
1686
vim.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
25896
end, { desc = "copy test command" })
259-
260-
pcall(vim.cmd, "TSContextEnable")

home/nvim/ftplugin/javascript.lua

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

home/nvim/ftplugin/lua.lua

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
11
-- indent
22
vim.opt.tabstop = 2
33
vim.opt.expandtab = true
4-
5-
-- lsp
6-
vim.lsp.start({
7-
name = "lua_ls",
8-
cmd = { "lua-language-server" },
9-
filetypes = { "lua" },
10-
root_dir = vim.fs.dirname(vim.fs.find({ ".stylua.toml", ".git/" }, { upward = true })[1]),
11-
single_file_support = true,
12-
log_level = vim.lsp.protocol.MessageType.Warning,
13-
settings = {
14-
Lua = {
15-
telemetry = { enable = false },
16-
diagnostics = {
17-
disable = { "missing-fields" },
18-
},
19-
},
20-
},
21-
})

home/nvim/ftplugin/markdown.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
-- no default autopair
22
vim.b.minipairs_disable = true
33

4-
-- autopair codefence on newline
5-
vim.keymap.set("i", "```<cr>", "```<cr>```<esc>O", { noremap = true })
6-
74
-- format
85
vim.opt.textwidth = 100
96
vim.opt.wrap = true

home/nvim/ftplugin/nix.lua

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,3 @@ vim.opt.commentstring = "# %s"
33
-- indent
44
vim.opt.tabstop = 2
55
vim.opt.expandtab = true
6-
7-
-- lsp
8-
vim.lsp.start({
9-
name = "nixd",
10-
cmd = { "nixd" },
11-
filetypes = { "nix" },
12-
single_file_support = true,
13-
root_dir = vim.fs.dirname(vim.fs.find({ "flake.nix", ".git/" }, { upward = true })[1]),
14-
})

home/nvim/ftplugin/templ.lua

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

home/nvim/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require("aucmd")
22
require("options")
33
require("maps")
4+
require("lsp")
45

56
local lazypath = vim.fn.stdpath("data") .. "/nixpkgs/lazy-nvim"
67
vim.opt.rtp:prepend(lazypath)

home/nvim/lua/aucmd.lua

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,3 @@
1-
-- add this functionality when LSP attaches
2-
vim.api.nvim_create_autocmd("LspAttach", {
3-
group = vim.api.nvim_create_augroup("on_lsp_attach", {}),
4-
callback = function(event)
5-
-- commands
6-
vim.api.nvim_buf_create_user_command(event.buf, "LspFormat", function(_)
7-
vim.lsp.buf.format()
8-
end, { desc = "Format current buffer with LSP" })
9-
vim.api.nvim_buf_create_user_command(event.buf, "LspRestart", function(_)
10-
vim.lsp.stop_client(vim.lsp.get_clients(), true)
11-
vim.cmd("edit")
12-
end, { desc = "Restart all active LSP clients" })
13-
14-
-- mappings
15-
vim.keymap.set("n", "<cr>", function()
16-
vim.diagnostic.open_float()
17-
end, { buffer = event.buf, desc = "lsp: open diagnostic" })
18-
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = event.buf, desc = "lsp: show definition" })
19-
vim.keymap.set("n", "gD", vim.lsp.buf.type_definition, { buffer = event.buf, desc = "lsp: show type definition" })
20-
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { buffer = event.buf, desc = "lsp: show implementations" })
21-
vim.keymap.set("n", "<leader>r", vim.lsp.buf.rename, { buffer = event.buf, desc = "lsp: rename symbol" })
22-
vim.keymap.set("n", "<leader>?", vim.lsp.buf.code_action, { buffer = event.buf, desc = "lsp: run code action" })
23-
vim.keymap.set("n", "<leader>qd", vim.diagnostic.setqflist, { buffer = event.buf, desc = "lsp: list diagnostics" })
24-
vim.keymap.set("n", "<leader>qD", function()
25-
vim.diagnostic.setqflist({
26-
severity = vim.diagnostic.severity.ERROR,
27-
})
28-
end, { buffer = event.buf, desc = "lsp: list serious diagnostics" })
29-
vim.keymap.set("n", "gr", function()
30-
vim.lsp.buf.references({
31-
includeDeclaration = false,
32-
})
33-
end, { buffer = event.buf, desc = "lsp: show refs" })
34-
35-
-- autocmds
36-
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
37-
group = vim.api.nvim_create_augroup("draw_references_document_highlight", { clear = true }),
38-
callback = vim.lsp.buf.document_highlight,
39-
})
40-
vim.api.nvim_create_autocmd("CursorMoved", {
41-
group = vim.api.nvim_create_augroup("clear_references_document_highlight", { clear = true }),
42-
callback = vim.lsp.buf.clear_references,
43-
})
44-
end,
45-
})
46-
471
-- display help in a vertical split
482
vim.api.nvim_create_autocmd("BufWinEnter", {
493
group = vim.api.nvim_create_augroup("vertical_help", { clear = true }),
@@ -89,14 +43,26 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, {
8943
pattern = "*",
9044
callback = function()
9145
vim.cmd("clearjumps")
46+
47+
vim.lsp.start({
48+
cmd = { "typos-lsp" },
49+
root_dir = vim.fs.dirname(vim.fs.find({ "README.md", ".git/" }, { upward = true })[1]),
50+
single_file_support = true,
51+
init_options = {
52+
diagnosticSeverity = "hint",
53+
},
54+
})
9255
end,
9356
})
9457

9558
-- do on entering insert mode
9659
vim.api.nvim_create_autocmd({ "InsertEnter" }, {
9760
group = vim.api.nvim_create_augroup("on_insert_enter", { clear = true }),
9861
pattern = "*",
99-
callback = function()
62+
callback = function(event)
63+
if vim.bo[event.buf].ft:match("snacks.*") then
64+
return
65+
end
10066
vim.opt.relativenumber = false -- switch to real line numbers
10167
end,
10268
})
@@ -106,6 +72,9 @@ vim.api.nvim_create_autocmd({ "InsertLeave" }, {
10672
group = vim.api.nvim_create_augroup("on_insert_leave", { clear = true }),
10773
pattern = "*",
10874
callback = function(event)
75+
if vim.bo[event.buf].ft:match("snacks.*") or vim.bo[event.buf].ft == "minifiles" then
76+
return
77+
end
10978
if vim.bo[event.buf].ft == "qf" then
11079
vim.opt.relativenumber = false
11180
return

0 commit comments

Comments
 (0)