From 03622a3c5c15621ac35ee938c706164d6060c00b Mon Sep 17 00:00:00 2001 From: afranco Date: Sun, 20 Oct 2024 01:40:32 +0100 Subject: [PATCH] chore(nvim): obsidian, oil, markdown, fzf-lua, lsp visual code actions --- .config/nvim/lua/plugins/cmp.lua | 10 +++++ .config/nvim/lua/plugins/editing.lua | 30 +++++++++++++ .config/nvim/lua/plugins/fzf-lua.lua | 4 +- .config/nvim/lua/plugins/lsp.lua | 2 +- .config/nvim/lua/plugins/navigation.lua | 58 ++++++++++++++++++++++++- .config/nvim/lua/plugins/ui.lua | 35 ++++++++------- 6 files changed, 117 insertions(+), 22 deletions(-) diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 6d3367b..2e85eaf 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -108,6 +108,16 @@ return { }, { { name = "buffer", keyword_length = 5 }, }), + window = { + completion = { + border = "rounded", + winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", + }, + documentation = { + border = "rounded", + winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", + }, + } }) local cmp_autopairs = require("nvim-autopairs.completion.cmp") diff --git a/.config/nvim/lua/plugins/editing.lua b/.config/nvim/lua/plugins/editing.lua index 0088202..2e28a3a 100644 --- a/.config/nvim/lua/plugins/editing.lua +++ b/.config/nvim/lua/plugins/editing.lua @@ -22,4 +22,34 @@ return { }) end, }, + + { + "epwalsh/obsidian.nvim", + version = "v3.9.0", + lazy = true, + ft = "markdown", + dependencies = { + "nvim-lua/plenary.nvim", + }, + opts = { + workspaces = { + { + name = "tese", + path = "~/vaults/uni/tese/", + }, + { + name = "chronolens", + path = "~/vaults/uni/chronolens/", + }, + }, + completion = { + nvim_cmp = true, + min_chars = 2, + }, + picker = { + name = "fzf-lua", + }, + + }, + } } diff --git a/.config/nvim/lua/plugins/fzf-lua.lua b/.config/nvim/lua/plugins/fzf-lua.lua index f13880c..4bae661 100644 --- a/.config/nvim/lua/plugins/fzf-lua.lua +++ b/.config/nvim/lua/plugins/fzf-lua.lua @@ -8,7 +8,6 @@ return { fzflua.register_ui_select() fzflua.setup({ defaults = { - headers = false, winopts = { border = "single", width = 0.6, @@ -19,7 +18,7 @@ return { previewer = false, winopts = { width = 0.5, - height = 0.3, + height = 0.5, } }, grep = { @@ -37,6 +36,7 @@ return { vim.keymap.set('n', 'fg', fzflua.live_grep, {}) vim.keymap.set('n', 'fb', fzflua.buffers, {}) vim.keymap.set('n', 'fh', fzflua.help_tags, {}) + vim.keymap.set({'n','v'}, 'fc', fzflua.commands, {}) end } } diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index e8412ec..04fa069 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -199,7 +199,7 @@ return { vim.keymap.set("n", "k", vim.lsp.buf.signature_help, bufopts) vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) vim.keymap.set("n", "rn", rename_func, bufopts_expr) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set({"n","v"}, "ca", vim.lsp.buf.code_action, bufopts) vim.keymap.set("n", "ge", vim.diagnostic.goto_next, bufopts) vim.keymap.set("n", "gE", vim.diagnostic.goto_prev, bufopts) vim.keymap.set("n", "fo", function() conform.format({ lsp_fallback = true }) end, bufopts) diff --git a/.config/nvim/lua/plugins/navigation.lua b/.config/nvim/lua/plugins/navigation.lua index 3952476..4370864 100644 --- a/.config/nvim/lua/plugins/navigation.lua +++ b/.config/nvim/lua/plugins/navigation.lua @@ -18,8 +18,64 @@ return { }, { "stevearc/oil.nvim", - opts = {}, + config = function() + require("oil").setup({ + float = { + preview_split = "right" + }, + }) + -- Function to open oil.nvim in a vertical split + local function open_oil_split() + -- Calculate the width for the split (20% of the total width) + local width = math.floor(vim.o.columns * 0.2) -- 20% of total width + -- Create a vertical split and set width + vim.cmd("vsplit") -- Create a vertical split + vim.cmd(string.format("vertical resize %d", width)) -- Resize to 20% + -- Open oil in the new split + require("oil").open() -- Use open() to open oil.nvim + end + + -- Key mapping to open oil in a vertical split + vim.api.nvim_set_keymap('n', 'o', ':lua require("oil").open_float()', { noremap = true, silent = true }) + vim.keymap.set('n', 'O', open_oil_split, { noremap = true, silent = true }) + + end }, + -- { + -- 'echasnovski/mini.files', + -- version = false, + -- opts = { + -- mappings = { + -- close = 'q', + -- go_in = '', + -- go_in_plus = 'l', + -- go_out = '', + -- go_out_plus = 'h', + -- reset = '', + -- show_help = 'g?', + -- synchronize = 's', + -- }, + -- options = { + -- permanent_delete = false + -- } + -- }, + -- keys = { + -- { + -- "o", + -- function() + -- require("mini.files").open(vim.api.nvim_buf_get_name(0), true) + -- end, + -- desc = "Open mini.files (Directory of the current file)" + -- }, + -- { + -- "O", + -- function() + -- require("mini.files").open(vim.uv.cwd(), true) + -- end, + -- desc = "Open mini.files (cwd)" + -- } + -- } + -- }, { 'mrjones2014/smart-splits.nvim', config = function() diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua index 02b5d59..b2b56bd 100644 --- a/.config/nvim/lua/plugins/ui.lua +++ b/.config/nvim/lua/plugins/ui.lua @@ -24,24 +24,23 @@ return { event = "VeryLazy", ft = 'qf' }, - { - "OXY2DEV/markview.nvim", - ft = "markdown", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons", - }, - opts = { - modes = { "n", "no", "i", "c" }, - hybrid_modes = { "i" }, - callbacks = { - on_enable = function(_, win) - vim.wo[win].conceallevel = 2; - vim.wo[win].concealcursor = "c"; - end - } - } - }, + -- { + -- "OXY2DEV/markview.nvim", + -- ft = "markdown", + -- dependencies = { + -- "nvim-treesitter/nvim-treesitter", + -- "nvim-tree/nvim-web-devicons", + -- }, + -- opts = { + -- modes = { "n", "no", "c" }, + -- callbacks = { + -- on_enable = function(_, win) + -- vim.wo[win].conceallevel = 2; + -- vim.wo[win].concealcursor = "c"; + -- end + -- } + -- } + -- }, { "folke/zen-mode.nvim", event = "VeryLazy",