From 2f3d89a4b8a6df4e338ba9dfe7892f6edc4fdcc7 Mon Sep 17 00:00:00 2001 From: KaasKop- Date: Thu, 28 Mar 2024 20:58:07 +0100 Subject: [PATCH] update to neovim --- config/nvim/lazyvim.json | 17 +--- config/nvim/lua/config/lazy.lua | 2 +- config/nvim/lua/config/options.lua | 9 +- config/nvim/lua/plugins/example.lua | 23 +---- config/nvim/lua/plugins/lazyvim.lua | 8 -- config/nvim/lua/plugins/neo-tree.lua | 107 +++++++++++++++++--- config/nvim/lua/plugins/nvim-treesitter.lua | 49 +++++---- 7 files changed, 127 insertions(+), 88 deletions(-) delete mode 100644 config/nvim/lua/plugins/lazyvim.lua diff --git a/config/nvim/lazyvim.json b/config/nvim/lazyvim.json index 65b2d90..e51e6d6 100644 --- a/config/nvim/lazyvim.json +++ b/config/nvim/lazyvim.json @@ -1,20 +1,9 @@ { "extras": [ - "lazyvim.plugins.extras.dap.core", - "lazyvim.plugins.extras.lang.clangd", - "lazyvim.plugins.extras.lang.cmake", - "lazyvim.plugins.extras.lang.docker", - "lazyvim.plugins.extras.lang.json", - "lazyvim.plugins.extras.lang.markdown", - "lazyvim.plugins.extras.lang.omnisharp", - "lazyvim.plugins.extras.lang.python", - "lazyvim.plugins.extras.lang.rust", - "lazyvim.plugins.extras.lang.tex", - "lazyvim.plugins.extras.lang.typescript", - "lazyvim.plugins.extras.lang.yaml" + ], "news": { - "NEWS.md": "2123" + "NEWS.md": "2850" }, - "version": 2 + "version": 3 } \ No newline at end of file diff --git a/config/nvim/lua/config/lazy.lua b/config/nvim/lua/config/lazy.lua index 75cb10d..891b190 100644 --- a/config/nvim/lua/config/lazy.lua +++ b/config/nvim/lua/config/lazy.lua @@ -26,7 +26,7 @@ require("lazy").setup({ version = false, -- always use the latest git commit -- version = "*", -- try installing the latest stable version for plugins that support semver }, - install = { colorscheme = { "tokyonight" } }, + install = { colorscheme = { "tokyonight", "habamax" } }, checker = { enabled = true }, -- automatically check for plugin updates performance = { rtp = { diff --git a/config/nvim/lua/config/options.lua b/config/nvim/lua/config/options.lua index 863ff10..785c746 100644 --- a/config/nvim/lua/config/options.lua +++ b/config/nvim/lua/config/options.lua @@ -1,12 +1,9 @@ -- Options are automatically loaded before lazy.nvim startup -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here -vim.g.autoformat = false + +LazyVim.terminal.setup("fish") local opt = vim.opt -opt.smartindent = true -opt.relativenumber = true -opt.clipboard = "unnamedplus" -opt.shell = "fish" -opt.spell = false +opt.mouse = "" diff --git a/config/nvim/lua/plugins/example.lua b/config/nvim/lua/plugins/example.lua index 4e7d409..de22bc8 100644 --- a/config/nvim/lua/plugins/example.lua +++ b/config/nvim/lua/plugins/example.lua @@ -30,14 +30,6 @@ return { -- disable trouble { "folke/trouble.nvim", enabled = false }, - -- add symbols-outline - { - "simrat39/symbols-outline.nvim", - cmd = "SymbolsOutline", - keys = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, - config = true, - }, - -- override nvim-cmp and add cmp-emoji { "hrsh7th/nvim-cmp", @@ -71,18 +63,6 @@ return { }, }, - -- add telescope-fzf-native - { - "telescope.nvim", - dependencies = { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - config = function() - require("telescope").load_extension("fzf") - end, - }, - }, - -- add pyright to lspconfig { "neovim/nvim-lspconfig", @@ -102,7 +82,7 @@ return { dependencies = { "jose-elias-alvarez/typescript.nvim", init = function() - require("lazyvim.util").on_attach(function(_, buffer) + require("lazyvim.util").lsp.on_attach(function(_, buffer) -- stylua: ignore vim.keymap.set( "n", "co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" }) vim.keymap.set("n", "cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer }) @@ -141,7 +121,6 @@ return { opts = { ensure_installed = { "bash", - "c_sharp", "html", "javascript", "json", diff --git a/config/nvim/lua/plugins/lazyvim.lua b/config/nvim/lua/plugins/lazyvim.lua deleted file mode 100644 index afbf38b..0000000 --- a/config/nvim/lua/plugins/lazyvim.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - { - "LazyVim/LazyVim", - opts = { - colorscheme = "tokyonight", - }, - }, -} diff --git a/config/nvim/lua/plugins/neo-tree.lua b/config/nvim/lua/plugins/neo-tree.lua index 74f91d3..251353f 100644 --- a/config/nvim/lua/plugins/neo-tree.lua +++ b/config/nvim/lua/plugins/neo-tree.lua @@ -1,27 +1,110 @@ return { "nvim-neo-tree/neo-tree.nvim", branch = "v3.x", + cmd = "Neotree", + keys = { + { + "fe", + function() + require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() }) + end, + desc = "Explorer NeoTree (Root Dir)", + }, + { + "fE", + function() + require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) + end, + desc = "Explorer NeoTree (cwd)", + }, + { "e", "fe", desc = "Explorer NeoTree (Root Dir)", remap = true }, + { "E", "fE", desc = "Explorer NeoTree (cwd)", remap = true }, + { + "ge", + function() + require("neo-tree.command").execute({ source = "git_status", toggle = true }) + end, + desc = "Git Explorer", + }, + { + "be", + function() + require("neo-tree.command").execute({ source = "buffers", toggle = true }) + end, + desc = "Buffer Explorer", + }, + }, + deactivate = function() + vim.cmd([[Neotree close]]) + end, + init = function() + if vim.fn.argc(-1) == 1 then + local stat = vim.uv.fs_stat(vim.fn.argv(0)) + if stat and stat.type == "directory" then + require("neo-tree") + end + end + end, opts = { + sources = { "filesystem", "buffers", "git_status", "document_symbols" }, + open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, filesystem = { - bind_to_cwd = true, + bind_to_cwd = false, + follow_current_file = { enabled = true }, + use_libuv_file_watcher = true, filtered_items = { visible = true, - hide_dotfiles = false, - hide_gitignored = false, - -- For windows - hide_hidden = false, + hide_dotfiles = true, + hide_gitignored = true, }, }, - close_if_last_window = false, window = { mappings = { - ["P"] = { "toggle_preview", config = { use_float = false, use_image_nvim = true } }, + [""] = "none", + ["Y"] = { + function(state) + local node = state.tree:get_node() + local path = node:get_id() + vim.fn.setreg("+", path, "c") + end, + desc = "Copy Path to Clipboard", + }, + ["O"] = { + function(state) + require("lazy.util").open(state.tree:get_node().path, { system = true }) + end, + desc = "Open with System Application", + }, + }, + }, + default_component_configs = { + indent = { + with_expanders = true, -- if nil and file nesting is enabled, will enable expanders + expander_collapsed = "", + expander_expanded = "", + expander_highlight = "NeoTreeExpander", }, }, }, - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, + config = function(_, opts) + local function on_move(data) + LazyVim.lsp.on_rename(data.source, data.destination) + end + + local events = require("neo-tree.events") + opts.event_handlers = opts.event_handlers or {} + vim.list_extend(opts.event_handlers, { + { event = events.FILE_MOVED, handler = on_move }, + { event = events.FILE_RENAMED, handler = on_move }, + }) + require("neo-tree").setup(opts) + vim.api.nvim_create_autocmd("TermClose", { + pattern = "*lazygit", + callback = function() + if package.loaded["neo-tree.sources.git_status"] then + require("neo-tree.sources.git_status").refresh() + end + end, + }) + end, } diff --git a/config/nvim/lua/plugins/nvim-treesitter.lua b/config/nvim/lua/plugins/nvim-treesitter.lua index 947813f..05824e7 100644 --- a/config/nvim/lua/plugins/nvim-treesitter.lua +++ b/config/nvim/lua/plugins/nvim-treesitter.lua @@ -1,29 +1,28 @@ return { - { - "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { - "bash", - "c_sharp", - "css", - "scss", - "dockerfile", - "html", - "javascript", - "json", - "lua", - "markdown", - "markdown_inline", - "sql", - "python", - "query", - "regex", - "tsx", - "typescript", - "vim", - "yaml", - "xml", - }, + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "bash", + "html", + "javascript", + "json", + "lua", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "tsx", + "typescript", + "vim", + "yaml", + "fish", + "sql", + "properties", + "rust", + "vue", + "xml", + "csv", }, }, }