Skip to content

Commit 9a5bc54

Browse files
committed
nvim stuffs
1 parent 00dddd6 commit 9a5bc54

File tree

6 files changed

+181
-265
lines changed

6 files changed

+181
-265
lines changed

home/nvim/ftplugin/go.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ vim.lsp.start({
3838
end,
3939
root_dir = vim.fs.dirname(vim.fs.find({ "go.mod", "go.sum", ".git/" }, { upward = true })[1]),
4040
single_file_support = true,
41-
capabilities = vim.lsp.protocol.make_client_capabilities(),
41+
-- capabilities = vim.lsp.protocol.make_client_capabilities(),
42+
capabilities = require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities()),
4243
settings = {
4344
gopls = {
4445
buildFlags = { "-tags=unit,integration,e2e" },
@@ -104,9 +105,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
104105
},
105106
},
106107
}, 10000)
107-
-- vim.lsp.buf.execute_command({
108-
-- command = "gopls.run_tests",
109-
-- })
110108
end, { desc = "lsp: run test at cursor", buffer = event.buf })
111109
end,
112110
})

home/nvim/go-textobjects.scm

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
;; extends
22

3-
; custom blocks without curlies
4-
(_
5-
(block . "{" . (_) @_start (_)? @_end . "}" (#make-range! "customblock.inner" @_start @_end)))
6-
7-
(if_statement
8-
(block . "{" . (_) @_start (_)? @_end . "}" (#make-range! "customconditional.inner" @_start @_end)))
9-
10-
(for_statement
11-
(block . "{" . (_) @_start (_)? @_end . "}" (#make-range! "customloop.inner" @_start @_end)))
12-
13-
; custom go type (@class includes literals?!)
14-
(type_declaration) @customtype.outer
15-
163
; add variadic_parameter_declaration
174
(parameter_list
185
.
@@ -24,14 +11,38 @@
2411
; peeking should show the body of functions and types
2512
[ (type_declaration) (function_declaration) (method_declaration) ] @peek
2613

27-
; custom go type bodies without curlies
14+
; struct and interface declaration as customtype textobject
15+
(type_declaration
16+
(type_spec
17+
(type_identifier)
18+
(struct_type))) @customtype.outer
19+
20+
(type_declaration
21+
(type_spec
22+
(type_identifier)
23+
(struct_type
24+
(field_declaration_list
25+
"{"
26+
.
27+
_ @_start @_end
28+
_? @_end
29+
.
30+
"}"
31+
(#make-range! "customtype.inner" @_start @_end)))))
32+
33+
(type_declaration
34+
(type_spec
35+
(type_identifier)
36+
(interface_type))) @customtype.outer
37+
2838
(type_declaration
2939
(type_spec
30-
name: (type_identifier)
31-
type: [
32-
(struct_type (field_declaration_list . "{" . (_) @_start @_end (_)? @_end . "}"))
33-
(interface_type . "{" . (_) @_start @_end (_)? @_end . "}")
34-
]
35-
(#make-range! "customtype.inner" @_start @_end)
36-
)
37-
)
40+
(type_identifier)
41+
(interface_type
42+
"{"
43+
.
44+
_ @_start @_end
45+
_? @_end
46+
.
47+
"}"
48+
(#make-range! "customtype.inner" @_start @_end))))

home/nvim/lua/aucmd.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ vim.api.nvim_create_autocmd("LspAttach", {
2323
end, { buffer = event.buf, desc = "lsp: show refs" })
2424
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { buffer = event.buf, desc = "lsp: show implementations" })
2525
vim.keymap.set("n", "go", vim.lsp.buf.document_symbol, { buffer = event.buf, desc = "lsp: outline symbols" })
26-
vim.keymap.set("n", "gq", vim.diagnostic.setqflist, { buffer = event.buf, desc = "lsp: list diagnostics" })
27-
vim.keymap.set("n", "gQ", function()
26+
vim.keymap.set("n", "<leader>qd", vim.diagnostic.setqflist, { buffer = event.buf, desc = "lsp: list diagnostics" })
27+
vim.keymap.set("n", "<leader>qD", function()
2828
vim.diagnostic.setqflist({ severity = vim.diagnostic.severity.ERROR })
2929
end, { buffer = event.buf, desc = "lsp: list serious diagnostics" })
3030
vim.keymap.set("n", "<leader>r", vim.lsp.buf.rename, { buffer = event.buf, desc = "lsp: rename symbol" })

home/nvim/lua/maps.lua

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -112,36 +112,6 @@ vim.keymap.set("n", "<leader>x", function()
112112
pcall(vim.cmd.NvimTreeRefresh)
113113
end, { desc = "close buffers not marked as persistent" })
114114

115-
-- copy git url
116-
vim.keymap.set({ "n", "x" }, "gy", function()
117-
-- base
118-
local url = "https://github.com/"
119-
-- repo
120-
local repo = vim.fn.systemlist("git config --get remote.origin.url")[1]
121-
local repo_nosuffix = string.gsub(repo, "(.*)%.git", "%1")
122-
local repo_path = string.gsub(repo_nosuffix, "git@github%.com:(.*)", "%1")
123-
repo_path = string.gsub(repo_path, "https://github%.com/(.*)", "%1")
124-
url = url .. repo_path .. "/blob/"
125-
-- revision
126-
local rev = vim.fn.systemlist("git rev-parse HEAD")[1]
127-
url = url .. rev
128-
-- path
129-
local fullpath = vim.fn.expand("%:p")
130-
local gitroot = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
131-
url = url .. fullpath:sub(#gitroot + 1, -1)
132-
-- lines
133-
local first, last
134-
if vim.fn.mode():lower() == "v" then
135-
first = vim.fn.getpos("v")[2]
136-
last = vim.fn.getpos(".")[2]
137-
else
138-
first = vim.fn.line(".")
139-
last = first
140-
end
141-
url = url .. "#L" .. first .. "-L" .. last
142-
vim.fn.setreg("+", url, "v")
143-
end, { silent = true, desc = "copy git url" })
144-
145115
-- banish weird default mappings
146116
vim.keymap.set("n", "gQ", "<nop>") -- ex mode
147117
vim.keymap.set({ "n", "x" }, "s", "<nop>") -- substitute char
@@ -166,7 +136,7 @@ vim.keymap.set("n", "dd", function()
166136
end, { desc = "delete line", expr = true })
167137

168138
-- open jumplist
169-
vim.keymap.set("n", "<leader>j", function()
139+
vim.keymap.set("n", "<leader>qj", function()
170140
local jumplist = vim.fn.getjumplist()[1]
171141
local qf_list = {}
172142
for _, v in ipairs(jumplist) do
@@ -183,7 +153,7 @@ vim.keymap.set("n", "<leader>j", function()
183153
vim.cmd.cwindow()
184154
end, { desc = "list jumplist" })
185155

186-
vim.keymap.set("n", "<leader>c", function()
156+
vim.keymap.set("n", "<leader>qc", function()
187157
local qf_list = {}
188158
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
189159
if vim.api.nvim_buf_is_loaded(buf) then

home/nvim/lua/options.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ vim.filetype.add({
7979
vim.diagnostic.config({
8080
severity_sort = true,
8181
})
82+
83+
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
84+
-- border = { "", "", "", "│", "", "", "", "│" },
85+
border = "none",
86+
max_width = 120,
87+
})

0 commit comments

Comments
 (0)