This commit is contained in:
Martin Larsson 2024-04-19 01:22:53 +02:00
commit 29859d95ec
8 changed files with 136 additions and 31 deletions

View file

@ -33,7 +33,7 @@ require("utils").add_keymaps({
}, },
-- Window -- Window
["<leader>x"] = { ["<C-x>"] = {
cmd = "<C-w>q", cmd = "<C-w>q",
}, },

View file

@ -3,7 +3,7 @@ return {
opts = { opts = {
show_icons = true, show_icons = true,
leader_key = ",", leader_key = ",",
global_bookmarks = true, global_bookmarks = false,
custom_actions = { custom_actions = {
open = function(filename, _) open = function(filename, _)
vim.cmd(string.format(":drop %s", filename)) vim.cmd(string.format(":drop %s", filename))

View file

@ -24,22 +24,23 @@ return {
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
}, },
{ {
{ name = "buffer" }, { name = "buffer" },
}) })
}) })
-- Set configuration for specific filetype. -- Set configuration for specific filetype.
cmp.setup.filetype("gitcommit", { cmp.setup.filetype("gitcommit", {
sources = cmp.config.sources({ sources = cmp.config.sources(
{ name = "git" }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). {
}, { { name = "git" }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
},
{
{ name = "buffer" }, { name = "buffer" },
}) })
}) })
@ -58,10 +59,9 @@ return {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "path" } { name = "path" }
}, { }, {
{ name = "cmdline" } { name = "cmdline" }
}), }),
matching = { disallow_symbol_nonprefix_matching = false } matching = { disallow_symbol_nonprefix_matching = false }
}) })
end, end,
} }

View file

@ -10,6 +10,9 @@ return {
window = { window = {
padding = 0, padding = 0,
}, },
hide = {
cursorline = true,
},
render = function(props) render = function(props)
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t") local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
if filename == "" then if filename == "" then

View file

@ -1,3 +1,31 @@
local buffers_without_inlay_hints = {}
local function set_inlay_hints_active(buffers, enable)
for _, bufnr in pairs(buffers) do
vim.lsp.inlay_hint.enable(bufnr, enable)
end
end
local function get_open_buffers_with_inlay_hints()
local buffers = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
local bufnr = vim.api.nvim_win_get_buf(win)
if vim.lsp.inlay_hint.is_enabled(bufnr) then
table.insert(buffers, bufnr)
end
end
return buffers
end
local function add_leap_autocmd(pattern, callback)
vim.api.nvim_create_autocmd("User", {
pattern = pattern,
callback = function()
callback()
end,
})
end
return { return {
"ggandor/leap.nvim", "ggandor/leap.nvim",
dependencies = { dependencies = {
@ -7,27 +35,26 @@ return {
local leap = require("leap") local leap = require("leap")
leap.opts.safe_labels = {} leap.opts.safe_labels = {}
-- Hide the (real) cursor when leaping, and restore it afterwards. local autocmds = {
vim.api.nvim_create_autocmd(
"User",
{ {
pattern = "LeapEnter", pattern = "LeapEnter",
callback = function() cb = function()
vim.cmd.hi("Cursor", "blend=100") local open_buffers = get_open_buffers_with_inlay_hints()
vim.opt.guicursor:append { "a:Cursor/lCursor" } set_inlay_hints_active(open_buffers, false)
end, buffers_without_inlay_hints = open_buffers
} end
) },
vim.api.nvim_create_autocmd(
"User",
{ {
pattern = "LeapLeave", pattern = "LeapLeave",
callback = function() cb = function()
vim.cmd.hi("Cursor", "blend=0") set_inlay_hints_active(buffers_without_inlay_hints, true)
vim.opt.guicursor:remove { "a:Cursor/lCursor" } end
end, },
} }
)
for _, cmd in ipairs(autocmds) do
add_leap_autocmd(cmd.pattern, cmd.cb)
end
require("utils").add_keymaps({ require("utils").add_keymaps({
n = { n = {

View file

@ -0,0 +1,22 @@
return {
"epwalsh/obsidian.nvim",
version = "*",
lazy = true,
ft = "markdown",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
local scndbrn_path = vim.fn.has("unixmac") == 1 and
"~/rp4-data/obsidian-vault/scndbrn" or
"/mnt/rp4-data/obsidian-vault/scndbrn"
require("obsidian").setup({
workspaces = {
{
name = "scndbrn",
path = scndbrn_path,
},
},
})
end,
}

View file

@ -25,6 +25,29 @@ return {
end, end,
}) })
end end
require("utils").add_keymaps({
n = {
["gd"] = {
cmd = function()
vim.lsp.buf.definition()
end,
opts = {
noremap = true,
silent = true
}
},
["gD"] = {
cmd = function()
vim.lsp.buf.declaration()
end,
opts = {
noremap = true,
silent = true
}
},
}
})
end, end,
} }
} }

View file

@ -0,0 +1,30 @@
return {
"folke/trouble.nvim",
branch = "dev",
opts = {},
config = {
require("utils").add_keymaps({
n = {
-- ["<leader>xx"] = {
-- cmd = "<cmd>Trouble diagnostics toggle<cr>",
-- },
-- ["<leader>xX"] = {
-- cmd = "<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
-- },
-- ["<leader>cs"] = {
-- cmd = "<cmd>Trouble symbols toggle focus=false<cr>",
-- },
-- ["<leader>cl"] = {
-- cmd = "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
-- },
-- ["<leader>xL"] = {
-- cmd = "<cmd>Trouble loclist toggle<cr>",
-- },
-- ["<leader>xQ"] = {
-- cmd = "<cmd>Trouble qflist toggle<cr>",
-- },
}
})
}
}