From 251e601eb883da010e91486651eb7d01f3a814ab Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 15 Sep 2025 13:28:36 +0200 Subject: [PATCH] Updated scripts --- config/nvim/init.lua | 83 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 451107a..041a1e3 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -73,9 +73,7 @@ local active_statusline = function() end local inactive_statusline = function() - return MiniStatusline.combine_groups({ - { hl = "MiniStatuslineDevinfo", strings = {} }, - }) + return active_statusline() end ------------------------------------------------------------------- @@ -93,20 +91,16 @@ vim.pack.add({ { src = "https://github.com/neovim/nvim-lspconfig" }, { src = "https://github.com/lewis6991/gitsigns.nvim" }, { src = "https://github.com/MunifTanjim/nui.nvim" }, - -- { src = "https://github.com/folke/noice.nvim" }, { src = "https://github.com/L3MON4D3/LuaSnip" }, { src = "https://github.com/rafamadriz/friendly-snippets" }, { src = "https://github.com/saghen/blink.cmp" }, { src = "https://github.com/stevearc/conform.nvim" }, - { src = "https://github.com/prichrd/netrw.nvim" }, { src = "https://github.com/nvim-tree/nvim-tree.lua" }, }) ------------------------------------------------------------------- -- Plugin config ------------------------------------------------------------------- --- require("noice").setup() -require("netrw").setup() require("conform").setup({ formatters_by_ft = { lua = { "stylua" }, @@ -183,13 +177,81 @@ require("blink.cmp").setup({ }, fuzzy = { implementation = "lua" }, }) -require("nvim-tree").setup() +require("nvim-tree").setup({ + view = { + -- Ensures files open in the window where nvim-tree was triggered + preserve_window_proportions = true, + }, + update_focused_file = { + enable = true, -- update the tree to focus the current file + update_root = false, -- don't change the root dir automatically + ignore_list = {}, -- you can add filetypes to ignore (e.g. "help") + }, + actions = { + open_file = { + quit_on_open = true, -- auto-close tree when file is opened + resize_window = true, + window_picker = { + enable = false, -- disable asking which window to use + }, + }, + }, +}) ------------------------------------------------------------------- -- LSP config ------------------------------------------------------------------- vim.lsp.enable({ "lua_ls", "rust_analyzer", "bashls", "pyright", "marksman", "clangd", "yamlls" }) +local Input = require("nui.input") +local event = require("nui.utils.autocmd").event + +local function lsp_rename() + local curr_name = vim.fn.expand("") + + local client = vim.lsp.get_clients({ bufnr = 0 })[1] + local offset_encoding = client and client.offset_encoding or "utf-16" + local pos_params = vim.lsp.util.make_position_params(0, offset_encoding) + + local input = Input({ + position = { + row = vim.fn.winline(), + col = vim.fn.wincol(), + }, + size = #curr_name + 10, + border = { + style = "rounded", + text = { top = "Rename", top_align = "left" }, + }, + }, { + prompt = "", + default_value = curr_name, + on_submit = function(new_name) + if new_name and #new_name > 0 and new_name ~= curr_name then + local params = { + textDocument = pos_params.textDocument, + position = pos_params.position, + newName = new_name, + } + -- send to all clients attached to buffer + vim.lsp.buf_request(0, "textDocument/rename", params) + end + end, + }) + + input:mount() + + input:on(event.BufLeave, function() + input:unmount() + end) + input:map("i", "", function() + input:unmount() + end, { noremap = true, nowait = true }) + input:map("n", "", function() + input:unmount() + end, { noremap = true, nowait = true }) +end + ------------------------------------------------------------------- -- GUI config ------------------------------------------------------------------- @@ -235,16 +297,15 @@ map("n", "u", ":update :source", { noremap = true, silent = true map("n", "w", ":write", { noremap = true, silent = true }) map("n", "q", ":quit", { noremap = true, silent = true }) map("n", "v", ":vsplit", { noremap = true, silent = true }) -map("n", "", "zz", { noremap = true, silent = true }) -map("n", "", "zz", { noremap = true, silent = true }) map("n", "n", "nzzzv", { noremap = true, silent = true }) map("n", "N", "Nzzzv", { noremap = true, silent = true }) +-- vim.keymap.set("n", "grn", lsp_rename, { desc = "LSP Rename (popup)" }) + -- Git map("n", "g", ":LazyGitCurrentFile", { noremap = true, silent = true }) -- File browser --- map("n", "e", ":25Lex", { noremap = true, silent = true }) map("n", "e", ":NvimTreeToggle", { noremap = true, silent = true }) map("n", "f", ":Pick files", { noremap = true, silent = true }) map("n", "h", ":Pick help", { noremap = true, silent = true })