From 1d962afb57e616e283eb19373c1d2062ab656b50 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 11 May 2025 15:52:21 +0200 Subject: changed some things in the neovim config. --- nvim/lua/configs.lua | 175 +++++++++++++++++++++++++++++++++++++--------- nvim/lua/core/keymaps.lua | 25 ++++--- nvim/lua/plugins.lua | 1 - 3 files changed, 159 insertions(+), 42 deletions(-) diff --git a/nvim/lua/configs.lua b/nvim/lua/configs.lua index 92d26f7..cb8c952 100644 --- a/nvim/lua/configs.lua +++ b/nvim/lua/configs.lua @@ -59,7 +59,6 @@ end -------------------------------- local function setup_harpoon() local harpoon = require("harpoon") - -- Initialize harpoon harpoon:setup({ settings = { @@ -76,16 +75,13 @@ local function setup_oil() require("oil").setup({ -- Default file explorer settings default_file_explorer = true, - -- Columns to display columns = { "icon" }, - -- Buffer options buf_options = { buflisted = false, bufhidden = "hide", }, - -- Window options win_options = { wrap = false, @@ -97,17 +93,14 @@ local function setup_oil() conceallevel = 3, concealcursor = "nvic", }, - -- File operations delete_to_trash = true, skip_confirm_for_simple_edits = false, prompt_save_on_select_new_entry = true, cleanup_delay_ms = 2000, - -- UI behavior constrain_cursor = "editable", watch_for_changes = false, - -- Custom keymaps keymaps = { ["g?"] = "actions.show_help", @@ -133,10 +126,8 @@ local function setup_oil() end, }, }, - -- Disable default keymaps use_default_keymaps = false, - -- View options view_options = { show_hidden = false, @@ -147,7 +138,6 @@ local function setup_oil() { "name", "asc" }, }, }, - -- Preview window settings preview = { max_width = 0.9, @@ -157,7 +147,6 @@ local function setup_oil() border = "rounded", win_options = { winblend = 0 }, }, - -- Floating window settings float = { padding = 2, @@ -176,22 +165,18 @@ local function setup_toggleterm() require("toggleterm").setup({ -- Shell to use in the terminal shell = "pwsh.exe -NoLogo", - -- Display options direction = "float", float_opts = { border = "rounded", }, - -- Window appearance winbar = { enabled = false }, - -- Behavior start_in_insert = true, close_on_exit = true, - -- Integration with tmux persist_size = true, persist_mode = true, @@ -233,33 +218,159 @@ end -------------------------------- -- LSP Configuration -------------------------------- +local path = require("mason-core.path") local function setup_lsp() -- Configure Mason LSP installer/manager require('mason').setup({ + ---@since 1.0.0 + -- The directory in which to install packages. + install_root_dir = path.concat { vim.fn.stdpath "data", "mason" }, + + ---@since 1.0.0 + -- Where Mason should put its bin location in your PATH. Can be one of: + -- - "prepend" (default, Mason's bin location is put first in PATH) + -- - "append" (Mason's bin location is put at the end of PATH) + -- - "skip" (doesn't modify PATH) + ---@type '"prepend"' | '"append"' | '"skip"' + PATH = "prepend", + + ---@since 1.0.0 + -- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when + -- debugging issues with package installations. + log_level = vim.log.levels.INFO, + + ---@since 1.0.0 + -- Limit for the maximum amount of packages to be installed at the same time. Once this limit is reached, any further + -- packages that are requested to be installed will be put in a queue. + max_concurrent_installers = 4, + + ---@since 1.0.0 + -- [Advanced setting] + -- The registries to source packages from. Accepts multiple entries. Should a package with the same name exist in + -- multiple registries, the registry listed first will be used. + registries = { + "github:mason-org/mason-registry", + }, + + ---@since 1.0.0 + -- The provider implementations to use for resolving supplementary package metadata (e.g., all available versions). + -- Accepts multiple entries, where later entries will be used as fallback should prior providers fail. + -- Builtin providers are: + -- - mason.providers.registry-api - uses the https://api.mason-registry.dev API + -- - mason.providers.client - uses only client-side tooling to resolve metadata + providers = { + "mason.providers.registry-api", + "mason.providers.client", + }, + + github = { + ---@since 1.0.0 + -- The template URL to use when downloading assets from GitHub. + -- The placeholders are the following (in order): + -- 1. The repository (e.g. "rust-lang/rust-analyzer") + -- 2. The release version (e.g. "v0.3.0") + -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz") + download_url_template = "https://github.com/%s/releases/download/%s/%s", + }, + + pip = { + ---@since 1.0.0 + -- Whether to upgrade pip to the latest version in the virtual environment before installing packages. + upgrade_pip = false, + + ---@since 1.0.0 + -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior + -- and is not recommended. + -- + -- Example: { "--proxy", "https://proxyserver" } + install_args = {}, + }, + + ui = { + ---@since 1.0.0 + -- Whether to automatically check for new versions when opening the :Mason window. + check_outdated_packages_on_open = true, + + ---@since 1.0.0 + -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. + -- Defaults to `:h 'winborder'` if nil. + border = nil, + + ---@since 1.11.0 + -- The backdrop opacity. 0 is fully opaque, 100 is fully transparent. + backdrop = 60, + + ---@since 1.0.0 + -- Width of the window. Accepts: + -- - Integer greater than 1 for fixed width. + -- - Float in the range of 0-1 for a percentage of screen width. + width = 0.8, + + ---@since 1.0.0 + -- Height of the window. Accepts: + -- - Integer greater than 1 for fixed height. + -- - Float in the range of 0-1 for a percentage of screen height. + height = 0.9, + + icons = { + ---@since 1.0.0 + -- The list icon to use for installed packages. + package_installed = "◍", + ---@since 1.0.0 + -- The list icon to use for packages that are installing, or queued for installation. + package_pending = "◍", + ---@since 1.0.0 + -- The list icon to use for packages that are not installed. + package_uninstalled = "◍", + }, + + keymaps = { + ---@since 1.0.0 + -- Keymap to expand a package + toggle_package_expand = "", + ---@since 1.0.0 + -- Keymap to install the package under the current cursor position + install_package = "i", + ---@since 1.0.0 + -- Keymap to reinstall/update the package under the current cursor position + update_package = "u", + ---@since 1.0.0 + -- Keymap to check for new version for the package under the current cursor position + check_package_version = "c", + ---@since 1.0.0 + -- Keymap to update all installed packages + update_all_packages = "U", + ---@since 1.0.0 + -- Keymap to check which installed packages are outdated + check_outdated_packages = "C", + ---@since 1.0.0 + -- Keymap to uninstall a package + uninstall_package = "X", + ---@since 1.0.0 + -- Keymap to cancel a package installation + cancel_installation = "", + ---@since 1.0.0 + -- Keymap to apply language filter + apply_language_filter = "", + ---@since 1.1.0 + -- Keymap to toggle viewing package installation log + toggle_package_install_log = "", + ---@since 1.8.0 + -- Keymap to toggle the help view + toggle_help = "g?", + }, + }, + }) + require("mason-lspconfig").setup ({ ensure_installed = { 'lua_ls', -- Lua 'clangd', -- C/C++ 'pyright', -- Python 'marksman', -- Markdown }, - handlers = { - -- Lua LSP settings - lua_ls = function() - require('lspconfig').lua_ls.setup({}) - end, - - -- C/C++ LSP settings (clangd) - clangd = function() - require('lspconfig').clangd.setup({}) - end, - - -- Markdown LSP settings - marksman = function() - require('lspconfig').marksman.setup({}) - end, - } + automatic_enable = true, + }) - require("mason-lspconfig").setup {} -- Configure diagnostics appearance vim.diagnostic.config({ diff --git a/nvim/lua/core/keymaps.lua b/nvim/lua/core/keymaps.lua index 0ab02ff..a65133d 100644 --- a/nvim/lua/core/keymaps.lua +++ b/nvim/lua/core/keymaps.lua @@ -48,7 +48,7 @@ vim.keymap.set("n", "j", "lprevzz", { desc = "Previous quickfix vim.keymap.set("n", "U", "", { desc = "Redo" }) -- Search and replace current word -vim.keymap.set("n", "s", [[:%s/\<\>//gI]], +vim.keymap.set("n", "s", [[:%s/\<\>//gI]], { desc = "Replace current word" }) -- Terminal keymaps @@ -61,13 +61,20 @@ vim.keymap.set("v","", ":ToggleTermSendVisualLines", { desc = -- File browser vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory with Oil" }) --- LSP quick diagnostics +-- LSP +-- Jump to definition with gd +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {noremap=true, silent=true}) +-- Optional: Add other useful LSP keybindings +vim.keymap.set('n', 'gr', vim.lsp.buf.references, {noremap=true, silent=true}) +vim.keymap.set('n', 'K', vim.lsp.buf.hover, {noremap=true, silent=true}) +vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, {noremap=true, silent=true}) +vim.keymap.set('n', '', vim.lsp.buf.signature_help, {noremap=true, silent=true}) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { noremap=true, silent=true, desc = "Show diagnostics" }) -- Python docstring helper -vim.keymap.set("n", "dc", ":PythonDocstring", { - silent = true, - desc = "Insert Python docstring template" +vim.keymap.set("n", "dc", ":PythonDocstring", { + silent = true, + desc = "Insert Python docstring template" }) ---------------- @@ -100,10 +107,10 @@ vim.keymap.set("n", "b", "Telescope buffers theme=dropdown", { -- Harpoon keymaps vim.keymap.set("n", "a", function() require("harpoon"):list():add() end, { desc = "Add file to harpoon" }) vim.keymap.set("n", "", function() require("harpoon").ui:toggle_quick_menu(require("harpoon"):list()) end, { desc = "Toggle harpoon menu" }) -vim.keymap.set("n", "h", function() require("harpoon"):list():select(1) end, { desc = "Harpoon file 1" }) -vim.keymap.set("n", "j", function() require("harpoon"):list():select(2) end, { desc = "Harpoon file 2" }) -vim.keymap.set("n", "k", function() require("harpoon"):list():select(3) end, { desc = "Harpoon file 3" }) -vim.keymap.set("n", "l", function() require("harpoon"):list():select(4) end, { desc = "Harpoon file 4" }) +vim.keymap.set("n", "j", function() require("harpoon"):list():select(1) end, { desc = "Harpoon file 1" }) +vim.keymap.set("n", "k", function() require("harpoon"):list():select(2) end, { desc = "Harpoon file 2" }) +vim.keymap.set("n", "l", function() require("harpoon"):list():select(3) end, { desc = "Harpoon file 3" }) +vim.keymap.set("n", ";", function() require("harpoon"):list():select(4) end, { desc = "Harpoon file 4" }) vim.keymap.set("n", "N", function() require("harpoon"):list():prev() end, { desc = "Previous harpoon file" }) vim.keymap.set("n", "P", function() require("harpoon"):list():next() end, { desc = "Next harpoon file" }) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index a04187c..0c9acbb 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -116,7 +116,6 @@ require("lazy").setup({ ------------------------------------------------------------ -- LSP & COMPLETION ------------------------------------------------------------ - -- LSP Base { "mason-org/mason.nvim", -- cgit v1.2.3