Skip to content

Commit

Permalink
preparing for the latest neovim
Browse files Browse the repository at this point in the history
Signed-off-by: abzcoding <[email protected]>
  • Loading branch information
abzcoding committed May 23, 2024
1 parent 756bf8a commit 99d55dc
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 143 deletions.
1 change: 1 addition & 0 deletions .vale/gitlab/Acronyms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ exceptions:
- LESS
- LFS
- LIDAR
- LLVM
- LNK
- LRU
- LSA
Expand Down
12 changes: 3 additions & 9 deletions ftplugin/java.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ if #launcher_path == 0 then
launcher_path = vim.fn.glob(mason_path .. "/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar", true, true)[1]
end
local CONFIG = "linux"
if vim.fn.has "mac" == 1 then
WORKSPACE_PATH = home .. "/workspace/"
CONFIG = "mac"
elseif vim.fn.has "unix" == 1 then
WORKSPACE_PATH = home .. "/workspace/"
else
local WORKSPACE_PATH = home .. "/workspace/"
if vim.fn.has "mac" ~= 1 and vim.fn.has "unix" ~= 1 then
vim.notify("Unsupported system", vim.log.levels.ERROR)
end

Expand All @@ -37,9 +33,7 @@ local workspace_dir = WORKSPACE_PATH .. project_name
-- Test bundle
-- Run :MasonInstall java-test
local bundles = { vim.fn.glob(mason_path .. "/packages/java-test/extension/server/*.jar", true) }
if #bundles == 0 then
bundles = { vim.fn.glob(mason_path .. "/packages/java-test/extension/server/*.jar", true) }
end

-- Debug bundle
-- Run :MasonInstall java-debug-adapter
local extra_bundles =
Expand Down
112 changes: 57 additions & 55 deletions lua/telescope/_extensions/luasnip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,63 +112,65 @@ local luasnip_fn = function(opts)
}
end

pickers.new(opts, {
prompt_title = "LuaSnip",
finder = finders.new_table {

results = objs,
entry_maker = function(entry)
return {
value = entry,
display = make_display,

ordinal = entry.ft
.. " "
.. filter_null(entry.context.trigger)
.. " "
.. filter_null(entry.context.name)
.. " "
.. filter_description(entry.context.name, entry.context.description),

preview_command = function(_, bufnr)
local snippet = get_docstring(luasnip, entry.ft, entry.context)
vim.api.nvim_buf_set_option(bufnr, "filetype", entry.ft)
if type(snippet) ~= "table" then
local lines = {}
for s in snippet:gmatch "[^\r\n]+" do
table.insert(lines, s)
pickers
.new(opts, {
prompt_title = "LuaSnip",
finder = finders.new_table {

results = objs,
entry_maker = function(entry)
return {
value = entry,
display = make_display,

ordinal = entry.ft
.. " "
.. filter_null(entry.context.trigger)
.. " "
.. filter_null(entry.context.name)
.. " "
.. filter_description(entry.context.name, entry.context.description),

preview_command = function(_, bufnr)
local snippet = get_docstring(luasnip, entry.ft, entry.context)
vim.api.nvim_set_option_value("filetype", entry.ft, { buf = bufnr })
if type(snippet) ~= "table" then
local lines = {}
for s in snippet:gmatch "[^\r\n]+" do
table.insert(lines, s)
end
snippet = lines
end
snippet = lines
end
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, snippet)
end,
}
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, snippet)
end,
}
end,
},

previewer = previewers.display_content.new(opts),
sorter = conf.generic_sorter(opts),
attach_mappings = function()
actions.select_default:replace(function(prompt_bufnr)
local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)
vim.api.nvim_put({ selection.value.context.trigger }, "", true, true)
if luasnip.expandable() then
vim.cmd "startinsert"
luasnip.expand()
vim.cmd "stopinsert"
else
print(
"Snippet '"
.. selection.value.context.name
.. "'"
.. "was selected, but LuaSnip.expandable() returned false"
)
end
end)
return true
end,
},

previewer = previewers.display_content.new(opts),
sorter = conf.generic_sorter(opts),
attach_mappings = function()
actions.select_default:replace(function(prompt_bufnr)
local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)
vim.api.nvim_put({ selection.value.context.trigger }, "", true, true)
if luasnip.expandable() then
vim.cmd "startinsert"
luasnip.expand()
vim.cmd "stopinsert"
else
print(
"Snippet '"
.. selection.value.context.name
.. "'"
.. "was selected, but LuaSnip.expandable() returned false"
)
end
end)
return true
end,
}):find()
})
:find()
end -- end custom function

return telescope.register_extension { exports = { luasnip = luasnip_fn } }
25 changes: 14 additions & 11 deletions lua/user/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,18 @@ M.config = function()
-- Treesitter
-- =========================================
lvim.builtin.treesitter.context_commentstring.enable = true
local languages = vim.tbl_flatten {
{ "bash", "c", "c_sharp", "cmake", "comment", "cpp", "css", "d", "dart" },
{ "dockerfile", "elixir", "elm", "erlang", "fennel", "fish", "go", "gomod" },
{ "gomod", "graphql", "hcl", "vimdoc", "html", "java", "javascript", "jsdoc" },
{ "json", "jsonc", "julia", "kotlin", "latex", "ledger", "lua", "make" },
{ "markdown", "markdown_inline", "nix", "ocaml", "perl", "php", "python" },
{ "query", "r", "regex", "rego", "ruby", "rust", "scala", "scss", "solidity" },
{ "swift", "teal", "toml", "tsx", "typescript", "vim", "vue", "yaml", "zig" },
}
local languages = vim
.iter({
{ "bash", "c", "c_sharp", "cmake", "comment", "cpp", "css", "d", "dart" },
{ "dockerfile", "elixir", "elm", "erlang", "fennel", "fish", "go", "gomod" },
{ "gomod", "graphql", "hcl", "vimdoc", "html", "java", "javascript", "jsdoc" },
{ "json", "jsonc", "julia", "kotlin", "latex", "ledger", "lua", "make" },
{ "markdown", "markdown_inline", "nix", "ocaml", "perl", "php", "python" },
{ "query", "r", "regex", "rego", "ruby", "rust", "scala", "scss", "solidity" },
{ "swift", "teal", "toml", "tsx", "typescript", "vim", "vue", "yaml", "zig" },
})
:flatten()
:totable()
lvim.builtin.treesitter.ensure_installed = languages
lvim.builtin.treesitter.highlight.disable = { "org" }
lvim.builtin.treesitter.highlight.aditional_vim_regex_highlighting = { "org" }
Expand Down Expand Up @@ -484,7 +487,7 @@ M.config = function()
-- results = {' ', '▐', '▄', '▌', '▌', '▐', '▟', '▙' };
preview = { " ", "", " ", "", "", "", "", "" },
}
lvim.builtin.telescope.defaults.selection_caret = " "
-- lvim.builtin.telescope.defaults.selection_caret = " "
lvim.builtin.telescope.defaults.cache_picker = { num_pickers = 3 }
lvim.builtin.telescope.defaults.layout_strategy = "horizontal"
lvim.builtin.telescope.defaults.file_ignore_patterns = {
Expand Down Expand Up @@ -935,7 +938,7 @@ M.enhanced_float_handler = function(handler)
local to
from, to = line:find(pattern, from)
if from then
vim.api.nvim_buf_set_extmark(buf, md_namespace, l - 1, from - 1, {
vim.api.nvim_buf_set_extmark(buf, -1, l - 1, from - 1, {
end_col = to,
hl_group = hl_group,
})
Expand Down
4 changes: 2 additions & 2 deletions lua/user/codelens.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end
M.show_line_sign = function()
-- Check for code action capability
local code_action_cap_found = false
for _, client in pairs(vim.lsp.buf_get_clients()) do
for _, client in pairs(vim.lsp.get_clients()) do
if client then
if client.supports_method("textDocument/codeAction") then
code_action_cap_found = true
Expand Down Expand Up @@ -134,7 +134,7 @@ end
--- @param text string the sign icon
---
M.update_sign = function(priority, old_line, new_line, bufnr, text)
bufnr = bufnr or "%"
bufnr = bufnr or 0

if old_line then
vim.fn.sign_unplace(SIGN_GROUP, { id = old_line, buffer = bufnr })
Expand Down
2 changes: 1 addition & 1 deletion lua/user/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ M.config = function()
python = function() end,
pythonPath = function()
local path
for _, server in pairs(vim.lsp.buf_get_clients()) do
for _, server in pairs(vim.lsp.get_clients()) do
if server.name == "pyright" or server.name == "pylance" then
path = vim.tbl_get(server, "config", "settings", "python", "pythonPath")
break
Expand Down
4 changes: 2 additions & 2 deletions lua/user/fzf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ local function hl_match(t)
return h
end
else
local ok, hl = pcall(vim.api.nvim_get_hl_by_name, h, true)
local ok, hl = vim.api.nvim_get_hl(0, { name = h })
-- must have at least bg or fg, otherwise this returns
-- succesffully for cleared highlights (on colorscheme switch)
if ok and (hl.foreground or hl.background) then
if ok and (hl.fg or hl.bg) then
return h
end
end
Expand Down
4 changes: 2 additions & 2 deletions lua/user/incline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ local function render(props)
if bufname == "" then
return "[No name]"
end
local ret = vim.api.nvim_get_hl_by_name("Directory", true)
local directory_color = string.format("#%06x", ret["foreground"])
local ret = vim.api.nvim_get_hl(0, { name = "Directory" })
local directory_color = string.format("#%06x", ret["fg"])
local parts = vim.split(vim.fn.fnamemodify(bufname, ":."), "/")
local result = {}
for idx, part in ipairs(parts) do
Expand Down
57 changes: 23 additions & 34 deletions lua/user/keybindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ M.config = function()
lvim.builtin.which_key.mappings["h"] = { "<cmd>nohlsearch<CR>", "󰸱 No Highlight" }
lvim.builtin.which_key.mappings.g.name = " Git"
if vim.fn.has "nvim-0.10" == 1 then

lvim.builtin.which_key.mappings["I"] = { "<cmd>lua require('user.neovim').inlay_hints()<cr>", " Toggle Inlay" }
end
lvim.builtin.which_key.mappings.l.name = " LSP"
Expand Down Expand Up @@ -501,57 +500,47 @@ M.config = function()
end

M.set_mind_keymaps = function()
local mind = require "mind"
lvim.builtin.which_key.mappings["M"] = {
name = " Mind",
c = {
function()
require("mind").wrap_smart_project_tree_fn(function(args)
require("mind.commands").create_node_index(
args.get_tree(),
require("mind.node").MoveDir.INSIDE_END,
args.save_tree,
args.opts
)
mind.wrap_smart_project_tree_fn(function(args)
mind.commands.create_node_index(args.get_tree(), mind.node.MoveDir.INSIDE_END, args.save_tree, args.opts)
end)
end,
"Create node index",
},
C = {
function()
require("mind").wrap_main_tree_fn(function(args)
require("mind.commands").create_node_index(
args.get_tree(),
require("mind.node").MoveDir.INSIDE_END,
args.save_tree,
args.opts
)
mind.wrap_main_tree_fn(function(args)
mind.commands.create_node_index(args.get_tree(), mind.node.MoveDir.INSIDE_END, args.save_tree, args.opts)
end)
end,
"Create node index",
},
i = {
function()
vim.notify "initializing project tree"
require("mind").wrap_smart_project_tree_fn(function(args)
mind.wrap_smart_project_tree_fn(function(args)
local tree = args.get_tree()
local mind_node = require "mind.node"

local _, tasks = mind_node.get_node_by_path(tree, "/Tasks", true)
local _, tasks = mind.node.get_node_by_path(tree, "/Tasks", true)
tasks.icon = ""

local _, backlog = mind_node.get_node_by_path(tree, "/Tasks/Backlog", true)
local _, backlog = mind.node.get_node_by_path(tree, "/Tasks/Backlog", true)
backlog.icon = ""

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

local _, done = mind_node.get_node_by_path(tree, "/Tasks/Done", true)
local _, done = mind.node.get_node_by_path(tree, "/Tasks/Done", true)
done.icon = "󱍧 "

local _, cancelled = mind_node.get_node_by_path(tree, "/Tasks/Cancelled", true)
local _, cancelled = mind.node.get_node_by_path(tree, "/Tasks/Cancelled", true)
cancelled.icon = ""

local _, notes = mind_node.get_node_by_path(tree, "/Notes", true)
local _, notes = mind.node.get_node_by_path(tree, "/Notes", true)
notes.icon = ""

args.save_tree()
Expand All @@ -561,33 +550,33 @@ M.set_mind_keymaps = function()
},
l = {
function()
require("mind").wrap_smart_project_tree_fn(function(args)
require("mind.commands").copy_node_link_index(args.get_tree(), nil, args.opts)
mind.wrap_smart_project_tree_fn(function(args)
mind.commands.copy_node_link_index(args.get_tree(), nil, args.opts)
end)
end,
"Copy node link index",
},
L = {
function()
require("mind").wrap_main_tree_fn(function(args)
require("mind.commands").copy_node_link_index(args.get_tree(), nil, args.opts)
mind.wrap_main_tree_fn(function(args)
mind.commands.copy_node_link_index(args.get_tree(), nil, args.opts)
end)
end,
"Copy node link index",
},
j = {
function()
require("mind").wrap_main_tree_fn(function(args)
mind.wrap_main_tree_fn(function(args)
local tree = args.get_tree()
local path = vim.fn.strftime "/Journal/%Y/%b/%d"
local _, node = require("mind.node").get_node_by_path(tree, path, true)
local _, node = mind.node.get_node_by_path(tree, path, true)

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

require("mind.commands").open_data(tree, node, args.data_dir, args.save_tree, args.opts)
mind.commands.open_data(tree, node, args.data_dir, args.save_tree, args.opts)
args.save_tree()
end)
end,
Expand All @@ -598,16 +587,16 @@ M.set_mind_keymaps = function()
m = { "<cmd>MindOpenSmartProject<CR>", "Open smart project tree" },
s = {
function()
require("mind").wrap_smart_project_tree_fn(function(args)
require("mind.commands").open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
mind.wrap_smart_project_tree_fn(function(args)
mind.commands.open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
end)
end,
"Open data index",
},
S = {
function()
require("mind").wrap_main_tree_fn(function(args)
require("mind.commands").open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
mind.wrap_main_tree_fn(function(args)
mind.commands.open_data_index(args.get_tree(), args.data_dir, args.save_tree, args.opts)
end)
end,
"Open data index",
Expand Down
2 changes: 0 additions & 2 deletions lua/user/legendary.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local M = {}

local function default_commands() end

M.config = function()
local status_ok, legend = pcall(require, "legendary")
if not status_ok then
Expand Down
Loading

0 comments on commit 99d55dc

Please sign in to comment.