From fd1d383b61d8f150016cf9ca14846abdec5ae015 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Wed, 17 Apr 2024 11:00:59 +0200 Subject: [PATCH 1/9] Hide incline if it is on the current cursos line --- nvim/lua/plugs/incline.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nvim/lua/plugs/incline.lua b/nvim/lua/plugs/incline.lua index 67221ca..afd2032 100644 --- a/nvim/lua/plugs/incline.lua +++ b/nvim/lua/plugs/incline.lua @@ -10,6 +10,9 @@ return { window = { padding = 0, }, + hide = { + cursorline = true, + }, render = function(props) local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t") if filename == "" then From d1e2e4dea6627246c92f70fd7b2416edc0bf3da6 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Wed, 17 Apr 2024 11:01:17 +0200 Subject: [PATCH 2/9] Add rust keybinds for lsp actions --- nvim/lua/plugs/rustaceanvim.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nvim/lua/plugs/rustaceanvim.lua b/nvim/lua/plugs/rustaceanvim.lua index 0148623..79b26bc 100644 --- a/nvim/lua/plugs/rustaceanvim.lua +++ b/nvim/lua/plugs/rustaceanvim.lua @@ -25,6 +25,29 @@ return { 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, } } From b9a4770fbe91396f8fea73b88465dfe080a51f1a Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Wed, 17 Apr 2024 11:01:32 +0200 Subject: [PATCH 3/9] Disable inlay hints during the leap motion --- nvim/lua/plugs/leap.lua | 61 +++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/nvim/lua/plugs/leap.lua b/nvim/lua/plugs/leap.lua index 41bdd1c..841b420 100644 --- a/nvim/lua/plugs/leap.lua +++ b/nvim/lua/plugs/leap.lua @@ -1,3 +1,31 @@ +local buffers_without_inlay_hints = {} +local function set_inlay_hints_active(buffers, enable) + for i, 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 { "ggandor/leap.nvim", dependencies = { @@ -7,27 +35,26 @@ return { local leap = require("leap") leap.opts.safe_labels = {} - -- Hide the (real) cursor when leaping, and restore it afterwards. - vim.api.nvim_create_autocmd( - "User", + local autocmds = { { pattern = "LeapEnter", - callback = function() - vim.cmd.hi("Cursor", "blend=100") - vim.opt.guicursor:append { "a:Cursor/lCursor" } - end, - } - ) - vim.api.nvim_create_autocmd( - "User", + cb = function() + local open_buffers = get_open_buffers_with_inlay_hints() + set_inlay_hints_active(open_buffers, false) + buffers_without_inlay_hints = open_buffers + end + }, { pattern = "LeapLeave", - callback = function() - vim.cmd.hi("Cursor", "blend=0") - vim.opt.guicursor:remove { "a:Cursor/lCursor" } - end, - } - ) + cb = function() + set_inlay_hints_active(buffers_without_inlay_hints, true) + end + }, + } + + for _, cmd in ipairs(autocmds) do + add_leap_autocmd(cmd.pattern, cmd.cb) + end require("utils").add_keymaps({ n = { From 033ee4d10e7d78b51e9ee641d165bd8d89896ed5 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Wed, 17 Apr 2024 11:01:50 +0200 Subject: [PATCH 4/9] Disable global bookmarks in arrow --- nvim/lua/plugs/arrow.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/lua/plugs/arrow.lua b/nvim/lua/plugs/arrow.lua index 4b8c916..164fb59 100644 --- a/nvim/lua/plugs/arrow.lua +++ b/nvim/lua/plugs/arrow.lua @@ -3,7 +3,7 @@ return { opts = { show_icons = true, leader_key = ",", - global_bookmarks = true, + global_bookmarks = false, custom_actions = { open = function(filename, _) vim.cmd(string.format(":drop %s", filename)) From 914299366f7c56ecffa5baae46770a65c21d4448 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 18 Apr 2024 09:20:11 +0200 Subject: [PATCH 5/9] Fix index in loop which isnt being used --- nvim/lua/plugs/leap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/lua/plugs/leap.lua b/nvim/lua/plugs/leap.lua index 841b420..07fc608 100644 --- a/nvim/lua/plugs/leap.lua +++ b/nvim/lua/plugs/leap.lua @@ -1,6 +1,6 @@ local buffers_without_inlay_hints = {} local function set_inlay_hints_active(buffers, enable) - for i, bufnr in pairs(buffers) do + for _, bufnr in pairs(buffers) do vim.lsp.inlay_hint.enable(bufnr, enable) end end From 8337ec9cb7691a85aa4be44ef20dae6112467dcc Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 18 Apr 2024 10:08:00 +0200 Subject: [PATCH 6/9] Add obsidian plugin, havent set up any bindings for it yet, just the basics --- nvim/lua/plugs/obsidian.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 nvim/lua/plugs/obsidian.lua diff --git a/nvim/lua/plugs/obsidian.lua b/nvim/lua/plugs/obsidian.lua new file mode 100644 index 0000000..b1c4bd3 --- /dev/null +++ b/nvim/lua/plugs/obsidian.lua @@ -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, +} From 6ff0c4c42b834eef093008f08fab70f4c9a58d7b Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 18 Apr 2024 10:38:43 +0200 Subject: [PATCH 7/9] Change bind for closing window to --- nvim/lua/keymaps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 3072394..afa6d5d 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -33,7 +33,7 @@ require("utils").add_keymaps({ }, -- Window - ["x"] = { + [""] = { cmd = "q", }, From 12030839251e655554655bae5bae333ff8c9a5ba Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 18 Apr 2024 10:39:43 +0200 Subject: [PATCH 8/9] Remove default C-e abort in cmp, and small refactorings --- nvim/lua/plugs/cmp.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nvim/lua/plugs/cmp.lua b/nvim/lua/plugs/cmp.lua index ad4f272..09a3b76 100644 --- a/nvim/lua/plugs/cmp.lua +++ b/nvim/lua/plugs/cmp.lua @@ -24,22 +24,23 @@ return { [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ - { name = "nvim_lsp" }, - }, - { - { name = "buffer" }, - }) + { name = "nvim_lsp" }, + }, + { + { name = "buffer" }, + }) }) -- Set configuration for specific filetype. cmp.setup.filetype("gitcommit", { - sources = cmp.config.sources({ - { name = "git" }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). - }, { + sources = cmp.config.sources( + { + { name = "git" }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, + { { name = "buffer" }, }) }) @@ -58,10 +59,9 @@ return { sources = cmp.config.sources({ { name = "path" } }, { - { name = "cmdline" } - }), + { name = "cmdline" } + }), matching = { disallow_symbol_nonprefix_matching = false } }) - end, } From 2e5aa86a3e0727bec87243f284b1a43a876634cd Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 18 Apr 2024 20:43:58 +0200 Subject: [PATCH 9/9] Add trouble to nvim, however, only the plugin, I have not yet customized anything. --- nvim/lua/plugs/trouble.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 nvim/lua/plugs/trouble.lua diff --git a/nvim/lua/plugs/trouble.lua b/nvim/lua/plugs/trouble.lua new file mode 100644 index 0000000..60e7c88 --- /dev/null +++ b/nvim/lua/plugs/trouble.lua @@ -0,0 +1,30 @@ +return { + "folke/trouble.nvim", + branch = "dev", + opts = {}, + config = { + + require("utils").add_keymaps({ + n = { + -- ["xx"] = { + -- cmd = "Trouble diagnostics toggle", + -- }, + -- ["xX"] = { + -- cmd = "Trouble diagnostics toggle filter.buf=0", + -- }, + -- ["cs"] = { + -- cmd = "Trouble symbols toggle focus=false", + -- }, + -- ["cl"] = { + -- cmd = "Trouble lsp toggle focus=false win.position=right", + -- }, + -- ["xL"] = { + -- cmd = "Trouble loclist toggle", + -- }, + -- ["xQ"] = { + -- cmd = "Trouble qflist toggle", + -- }, + } + }) + } +}