Skip to content

Commit 99d55dc

Browse files
committed
preparing for the latest neovim
Signed-off-by: abzcoding <abzcoding@gmail.com>
1 parent 756bf8a commit 99d55dc

File tree

17 files changed

+118
-143
lines changed

17 files changed

+118
-143
lines changed

.vale/gitlab/Acronyms.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ exceptions:
207207
- LESS
208208
- LFS
209209
- LIDAR
210+
- LLVM
210211
- LNK
211212
- LRU
212213
- LSA

ftplugin/java.lua

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ if #launcher_path == 0 then
1212
launcher_path = vim.fn.glob(mason_path .. "/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar", true, true)[1]
1313
end
1414
local CONFIG = "linux"
15-
if vim.fn.has "mac" == 1 then
16-
WORKSPACE_PATH = home .. "/workspace/"
17-
CONFIG = "mac"
18-
elseif vim.fn.has "unix" == 1 then
19-
WORKSPACE_PATH = home .. "/workspace/"
20-
else
15+
local WORKSPACE_PATH = home .. "/workspace/"
16+
if vim.fn.has "mac" ~= 1 and vim.fn.has "unix" ~= 1 then
2117
vim.notify("Unsupported system", vim.log.levels.ERROR)
2218
end
2319

@@ -37,9 +33,7 @@ local workspace_dir = WORKSPACE_PATH .. project_name
3733
-- Test bundle
3834
-- Run :MasonInstall java-test
3935
local bundles = { vim.fn.glob(mason_path .. "/packages/java-test/extension/server/*.jar", true) }
40-
if #bundles == 0 then
41-
bundles = { vim.fn.glob(mason_path .. "/packages/java-test/extension/server/*.jar", true) }
42-
end
36+
4337
-- Debug bundle
4438
-- Run :MasonInstall java-debug-adapter
4539
local extra_bundles =

lua/telescope/_extensions/luasnip.lua

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -112,63 +112,65 @@ local luasnip_fn = function(opts)
112112
}
113113
end
114114

115-
pickers.new(opts, {
116-
prompt_title = "LuaSnip",
117-
finder = finders.new_table {
118-
119-
results = objs,
120-
entry_maker = function(entry)
121-
return {
122-
value = entry,
123-
display = make_display,
124-
125-
ordinal = entry.ft
126-
.. " "
127-
.. filter_null(entry.context.trigger)
128-
.. " "
129-
.. filter_null(entry.context.name)
130-
.. " "
131-
.. filter_description(entry.context.name, entry.context.description),
132-
133-
preview_command = function(_, bufnr)
134-
local snippet = get_docstring(luasnip, entry.ft, entry.context)
135-
vim.api.nvim_buf_set_option(bufnr, "filetype", entry.ft)
136-
if type(snippet) ~= "table" then
137-
local lines = {}
138-
for s in snippet:gmatch "[^\r\n]+" do
139-
table.insert(lines, s)
115+
pickers
116+
.new(opts, {
117+
prompt_title = "LuaSnip",
118+
finder = finders.new_table {
119+
120+
results = objs,
121+
entry_maker = function(entry)
122+
return {
123+
value = entry,
124+
display = make_display,
125+
126+
ordinal = entry.ft
127+
.. " "
128+
.. filter_null(entry.context.trigger)
129+
.. " "
130+
.. filter_null(entry.context.name)
131+
.. " "
132+
.. filter_description(entry.context.name, entry.context.description),
133+
134+
preview_command = function(_, bufnr)
135+
local snippet = get_docstring(luasnip, entry.ft, entry.context)
136+
vim.api.nvim_set_option_value("filetype", entry.ft, { buf = bufnr })
137+
if type(snippet) ~= "table" then
138+
local lines = {}
139+
for s in snippet:gmatch "[^\r\n]+" do
140+
table.insert(lines, s)
141+
end
142+
snippet = lines
140143
end
141-
snippet = lines
142-
end
143-
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, snippet)
144-
end,
145-
}
144+
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, snippet)
145+
end,
146+
}
147+
end,
148+
},
149+
150+
previewer = previewers.display_content.new(opts),
151+
sorter = conf.generic_sorter(opts),
152+
attach_mappings = function()
153+
actions.select_default:replace(function(prompt_bufnr)
154+
local selection = action_state.get_selected_entry()
155+
actions.close(prompt_bufnr)
156+
vim.api.nvim_put({ selection.value.context.trigger }, "", true, true)
157+
if luasnip.expandable() then
158+
vim.cmd "startinsert"
159+
luasnip.expand()
160+
vim.cmd "stopinsert"
161+
else
162+
print(
163+
"Snippet '"
164+
.. selection.value.context.name
165+
.. "'"
166+
.. "was selected, but LuaSnip.expandable() returned false"
167+
)
168+
end
169+
end)
170+
return true
146171
end,
147-
},
148-
149-
previewer = previewers.display_content.new(opts),
150-
sorter = conf.generic_sorter(opts),
151-
attach_mappings = function()
152-
actions.select_default:replace(function(prompt_bufnr)
153-
local selection = action_state.get_selected_entry()
154-
actions.close(prompt_bufnr)
155-
vim.api.nvim_put({ selection.value.context.trigger }, "", true, true)
156-
if luasnip.expandable() then
157-
vim.cmd "startinsert"
158-
luasnip.expand()
159-
vim.cmd "stopinsert"
160-
else
161-
print(
162-
"Snippet '"
163-
.. selection.value.context.name
164-
.. "'"
165-
.. "was selected, but LuaSnip.expandable() returned false"
166-
)
167-
end
168-
end)
169-
return true
170-
end,
171-
}):find()
172+
})
173+
:find()
172174
end -- end custom function
173175

174176
return telescope.register_extension { exports = { luasnip = luasnip_fn } }

lua/user/builtin.lua

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,18 @@ M.config = function()
373373
-- Treesitter
374374
-- =========================================
375375
lvim.builtin.treesitter.context_commentstring.enable = true
376-
local languages = vim.tbl_flatten {
377-
{ "bash", "c", "c_sharp", "cmake", "comment", "cpp", "css", "d", "dart" },
378-
{ "dockerfile", "elixir", "elm", "erlang", "fennel", "fish", "go", "gomod" },
379-
{ "gomod", "graphql", "hcl", "vimdoc", "html", "java", "javascript", "jsdoc" },
380-
{ "json", "jsonc", "julia", "kotlin", "latex", "ledger", "lua", "make" },
381-
{ "markdown", "markdown_inline", "nix", "ocaml", "perl", "php", "python" },
382-
{ "query", "r", "regex", "rego", "ruby", "rust", "scala", "scss", "solidity" },
383-
{ "swift", "teal", "toml", "tsx", "typescript", "vim", "vue", "yaml", "zig" },
384-
}
376+
local languages = vim
377+
.iter({
378+
{ "bash", "c", "c_sharp", "cmake", "comment", "cpp", "css", "d", "dart" },
379+
{ "dockerfile", "elixir", "elm", "erlang", "fennel", "fish", "go", "gomod" },
380+
{ "gomod", "graphql", "hcl", "vimdoc", "html", "java", "javascript", "jsdoc" },
381+
{ "json", "jsonc", "julia", "kotlin", "latex", "ledger", "lua", "make" },
382+
{ "markdown", "markdown_inline", "nix", "ocaml", "perl", "php", "python" },
383+
{ "query", "r", "regex", "rego", "ruby", "rust", "scala", "scss", "solidity" },
384+
{ "swift", "teal", "toml", "tsx", "typescript", "vim", "vue", "yaml", "zig" },
385+
})
386+
:flatten()
387+
:totable()
385388
lvim.builtin.treesitter.ensure_installed = languages
386389
lvim.builtin.treesitter.highlight.disable = { "org" }
387390
lvim.builtin.treesitter.highlight.aditional_vim_regex_highlighting = { "org" }
@@ -484,7 +487,7 @@ M.config = function()
484487
-- results = {' ', '▐', '▄', '▌', '▌', '▐', '▟', '▙' };
485488
preview = { " ", "", " ", "", "", "", "", "" },
486489
}
487-
lvim.builtin.telescope.defaults.selection_caret = " "
490+
-- lvim.builtin.telescope.defaults.selection_caret = " "
488491
lvim.builtin.telescope.defaults.cache_picker = { num_pickers = 3 }
489492
lvim.builtin.telescope.defaults.layout_strategy = "horizontal"
490493
lvim.builtin.telescope.defaults.file_ignore_patterns = {
@@ -935,7 +938,7 @@ M.enhanced_float_handler = function(handler)
935938
local to
936939
from, to = line:find(pattern, from)
937940
if from then
938-
vim.api.nvim_buf_set_extmark(buf, md_namespace, l - 1, from - 1, {
941+
vim.api.nvim_buf_set_extmark(buf, -1, l - 1, from - 1, {
939942
end_col = to,
940943
hl_group = hl_group,
941944
})

lua/user/codelens.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212
M.show_line_sign = function()
1313
-- Check for code action capability
1414
local code_action_cap_found = false
15-
for _, client in pairs(vim.lsp.buf_get_clients()) do
15+
for _, client in pairs(vim.lsp.get_clients()) do
1616
if client then
1717
if client.supports_method("textDocument/codeAction") then
1818
code_action_cap_found = true
@@ -134,7 +134,7 @@ end
134134
--- @param text string the sign icon
135135
---
136136
M.update_sign = function(priority, old_line, new_line, bufnr, text)
137-
bufnr = bufnr or "%"
137+
bufnr = bufnr or 0
138138

139139
if old_line then
140140
vim.fn.sign_unplace(SIGN_GROUP, { id = old_line, buffer = bufnr })

lua/user/dap.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ M.config = function()
379379
python = function() end,
380380
pythonPath = function()
381381
local path
382-
for _, server in pairs(vim.lsp.buf_get_clients()) do
382+
for _, server in pairs(vim.lsp.get_clients()) do
383383
if server.name == "pyright" or server.name == "pylance" then
384384
path = vim.tbl_get(server, "config", "settings", "python", "pythonPath")
385385
break

lua/user/fzf.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ local function hl_match(t)
1010
return h
1111
end
1212
else
13-
local ok, hl = pcall(vim.api.nvim_get_hl_by_name, h, true)
13+
local ok, hl = vim.api.nvim_get_hl(0, { name = h })
1414
-- must have at least bg or fg, otherwise this returns
1515
-- succesffully for cleared highlights (on colorscheme switch)
16-
if ok and (hl.foreground or hl.background) then
16+
if ok and (hl.fg or hl.bg) then
1717
return h
1818
end
1919
end

lua/user/incline.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ local function render(props)
1212
if bufname == "" then
1313
return "[No name]"
1414
end
15-
local ret = vim.api.nvim_get_hl_by_name("Directory", true)
16-
local directory_color = string.format("#%06x", ret["foreground"])
15+
local ret = vim.api.nvim_get_hl(0, { name = "Directory" })
16+
local directory_color = string.format("#%06x", ret["fg"])
1717
local parts = vim.split(vim.fn.fnamemodify(bufname, ":."), "/")
1818
local result = {}
1919
for idx, part in ipairs(parts) do

lua/user/keybindings.lua

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ M.config = function()
333333
lvim.builtin.which_key.mappings["h"] = { "<cmd>nohlsearch<CR>", "󰸱 No Highlight" }
334334
lvim.builtin.which_key.mappings.g.name = " Git"
335335
if vim.fn.has "nvim-0.10" == 1 then
336-
337336
lvim.builtin.which_key.mappings["I"] = { "<cmd>lua require('user.neovim').inlay_hints()<cr>", " Toggle Inlay" }
338337
end
339338
lvim.builtin.which_key.mappings.l.name = " LSP"
@@ -501,57 +500,47 @@ M.config = function()
501500
end
502501

503502
M.set_mind_keymaps = function()
503+
local mind = require "mind"
504504
lvim.builtin.which_key.mappings["M"] = {
505505
name = " Mind",
506506
c = {
507507
function()
508-
require("mind").wrap_smart_project_tree_fn(function(args)
509-
require("mind.commands").create_node_index(
510-
args.get_tree(),
511-
require("mind.node").MoveDir.INSIDE_END,
512-
args.save_tree,
513-
args.opts
514-
)
508+
mind.wrap_smart_project_tree_fn(function(args)
509+
mind.commands.create_node_index(args.get_tree(), mind.node.MoveDir.INSIDE_END, args.save_tree, args.opts)
515510
end)
516511
end,
517512
"Create node index",
518513
},
519514
C = {
520515
function()
521-
require("mind").wrap_main_tree_fn(function(args)
522-
require("mind.commands").create_node_index(
523-
args.get_tree(),
524-
require("mind.node").MoveDir.INSIDE_END,
525-
args.save_tree,
526-
args.opts
527-
)
516+
mind.wrap_main_tree_fn(function(args)
517+
mind.commands.create_node_index(args.get_tree(), mind.node.MoveDir.INSIDE_END, args.save_tree, args.opts)
528518
end)
529519
end,
530520
"Create node index",
531521
},
532522
i = {
533523
function()
534524
vim.notify "initializing project tree"
535-
require("mind").wrap_smart_project_tree_fn(function(args)
525+
mind.wrap_smart_project_tree_fn(function(args)
536526
local tree = args.get_tree()
537-
local mind_node = require "mind.node"
538527

539-
local _, tasks = mind_node.get_node_by_path(tree, "/Tasks", true)
528+
local _, tasks = mind.node.get_node_by_path(tree, "/Tasks", true)
540529
tasks.icon = ""
541530

542-
local _, backlog = mind_node.get_node_by_path(tree, "/Tasks/Backlog", true)
531+
local _, backlog = mind.node.get_node_by_path(tree, "/Tasks/Backlog", true)
543532
backlog.icon = ""
544533

545-
local _, on_going = mind_node.get_node_by_path(tree, "/Tasks/On-going", true)
534+
local _, on_going = mind.node.get_node_by_path(tree, "/Tasks/On-going", true)
546535
on_going.icon = ""
547536

548-
local _, done = mind_node.get_node_by_path(tree, "/Tasks/Done", true)
537+
local _, done = mind.node.get_node_by_path(tree, "/Tasks/Done", true)
549538
done.icon = "󱍧 "
550539

551-
local _, cancelled = mind_node.get_node_by_path(tree, "/Tasks/Cancelled", true)
540+
local _, cancelled = mind.node.get_node_by_path(tree, "/Tasks/Cancelled", true)
552541
cancelled.icon = ""
553542

554-
local _, notes = mind_node.get_node_by_path(tree, "/Notes", true)
543+
local _, notes = mind.node.get_node_by_path(tree, "/Notes", true)
555544
notes.icon = ""
556545

557546
args.save_tree()
@@ -561,33 +550,33 @@ M.set_mind_keymaps = function()
561550
},
562551
l = {
563552
function()
564-
require("mind").wrap_smart_project_tree_fn(function(args)
565-
require("mind.commands").copy_node_link_index(args.get_tree(), nil, args.opts)
553+
mind.wrap_smart_project_tree_fn(function(args)
554+
mind.commands.copy_node_link_index(args.get_tree(), nil, args.opts)
566555
end)
567556
end,
568557
"Copy node link index",
569558
},
570559
L = {
571560
function()
572-
require("mind").wrap_main_tree_fn(function(args)
573-
require("mind.commands").copy_node_link_index(args.get_tree(), nil, args.opts)
561+
mind.wrap_main_tree_fn(function(args)
562+
mind.commands.copy_node_link_index(args.get_tree(), nil, args.opts)
574563
end)
575564
end,
576565
"Copy node link index",
577566
},
578567
j = {
579568
function()
580-
require("mind").wrap_main_tree_fn(function(args)
569+
mind.wrap_main_tree_fn(function(args)
581570
local tree = args.get_tree()
582571
local path = vim.fn.strftime "/Journal/%Y/%b/%d"
583-
local _, node = require("mind.node").get_node_by_path(tree, path, true)
572+
local _, node = mind.node.get_node_by_path(tree, path, true)
584573

585574
if node == nil then
586575
vim.notify("cannot open journal 🙁", vim.log.levels.WARN)
587576
return
588577
end
589578

590-
require("mind.commands").open_data(tree, node, args.data_dir, args.save_tree, args.opts)
579+
mind.commands.open_data(tree, node, args.data_dir, args.save_tree, args.opts)
591580
args.save_tree()
592581
end)
593582
end,
@@ -598,16 +587,16 @@ M.set_mind_keymaps = function()
598587
m = { "<cmd>MindOpenSmartProject<CR>", "Open smart project tree" },
599588
s = {
600589
function()
601-
require("mind").wrap_smart_project_tree_fn(function(args)
602-
require("mind.commands").open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
590+
mind.wrap_smart_project_tree_fn(function(args)
591+
mind.commands.open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
603592
end)
604593
end,
605594
"Open data index",
606595
},
607596
S = {
608597
function()
609-
require("mind").wrap_main_tree_fn(function(args)
610-
require("mind.commands").open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
598+
mind.wrap_main_tree_fn(function(args)
599+
mind.commands.open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
611600
end)
612601
end,
613602
"Open data index",

lua/user/legendary.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
local M = {}
22

3-
local function default_commands() end
4-
53
M.config = function()
64
local status_ok, legend = pcall(require, "legendary")
75
if not status_ok then

0 commit comments

Comments
 (0)