From 35af981c834ff951957de4962d8a26f5986284fc Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 18 Jun 2025 21:53:08 +0200 Subject: [PATCH] Merge changes from work --- nix/user/git.nix | 4 +++- nix/user/nvim.nix | 2 ++ nix/user/sh.nix | 2 +- nvim/base.lua | 45 ++++++++++++++++++++++++++++++++++++++++++--- nvim/keymaps.lua | 2 +- nvim/plugins.lua | 26 ++++++++++++++++++++++++-- 6 files changed, 73 insertions(+), 8 deletions(-) diff --git a/nix/user/git.nix b/nix/user/git.nix index 394125a..366588f 100644 --- a/nix/user/git.nix +++ b/nix/user/git.nix @@ -11,8 +11,10 @@ br = "branch"; pl = "pull"; ps = "push"; + sw = "switch"; mno =" merge --no-ff"; - lg = "log --color --graph --pretty=format:'%cred%h%creset -%c(yellow)%d%creset %s %cgreen(%cr)%c(bold blue)<%an>%creset' --abbrev-commit"; + lg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"; + cleanup = "!git fetch --prune && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D"; }; difftastic.enable = true; diff --git a/nix/user/nvim.nix b/nix/user/nvim.nix index 98b874b..4bc8d24 100644 --- a/nix/user/nvim.nix +++ b/nix/user/nvim.nix @@ -13,6 +13,7 @@ vim-commentary vim-repeat vim-surround + nvim-tree-lua targets-vim delimitMate # vim-startify @@ -42,6 +43,7 @@ img-clip-nvim markdown-preview-nvim vim-markdown + bullets-vim (nvim-treesitter.withPlugins (p: [ p.awk p.bash p.c p.c_sharp p.cpp p.css p.diff p.dockerfile p.doxygen p.git_config p.gitcommit p.go p.gomod p.gosum p.gotmpl p.helm p.haskell p.html p.http p.java p.javascript p.json p.latex p.lua p.markdown p.markdown_inline p.matlab p.nix p.printf p.python p.regex p.rust p.sql p.strace p.supercollider p.svelte p.swift p.terraform p.tmux p.toml p.typescript p.vim p.xml p.yaml p.zig ])) ]; diff --git a/nix/user/sh.nix b/nix/user/sh.nix index 3eee73c..eb4f996 100644 --- a/nix/user/sh.nix +++ b/nix/user/sh.nix @@ -65,7 +65,7 @@ programs.lsd = { enable = true; - enableAliases = true; + enableZshIntegration = true; }; programs.zoxide = { diff --git a/nvim/base.lua b/nvim/base.lua index 0fbe31c..62501f6 100644 --- a/nvim/base.lua +++ b/nvim/base.lua @@ -1,3 +1,6 @@ +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + ------------------------- -------- OPTIONS -------- ------------------------- @@ -46,14 +49,15 @@ vim.opt.autoread = true vim.opt.syntax = 'on' vim.opt.encoding = 'utf-8' vim.opt.completeopt = 'menu,menuone,noselect' +vim.opt.termguicolors = true ---------------------------- -------- CLIPBOARD --------- ---------------------------- --- if vim.fn.has("wsl") == 1 then -vim.opt.clipboard:append('unnamedplus') --- end +if vim.fn.has("wsl") == 1 then + vim.opt.clipboard = vim.opt.clipboard + 'unnamedplus' +end ---------------------------- @@ -84,6 +88,40 @@ vim.api.nvim_create_autocmd('BufEnter', { command = 'silent! lcd %:p:h' }) +-- Open nvim-tree when starting Neovim in a specific directory or any of its subdirectories +vim.api.nvim_create_autocmd("VimEnter", { + callback = function() + local args = vim.fn.argv() + + if #args > 0 then + local current_dir = vim.fn.fnamemodify(args[1], ":p:h") + local dir_name = vim.fn.fnamemodify(current_dir, ":t") + + -- Check if in a "notes" directory or its subdirectory + local in_notes = dir_name == "notes" + if not in_notes then + -- Check if any parent directory is named "notes" + local path_parts = vim.split(current_dir, "/", {plain = true}) + for i, part in ipairs(path_parts) do + if part == "notes" then + in_notes = true + break + end + end + end + + -- If in a notes directory or subdirectory, open the tree + if in_notes then + require("nvim-tree.api").tree.open() + vim.defer_fn(function() + require("nvim-tree.api").tree.expand_all() + -- After expanding, return focus to the main window/buffer + vim.cmd("wincmd p") + end, 100) -- Small delay to ensure tree is fully loaded before expanding + end + end + end +}) --------------------------- -------- FUNCTIONS -------- @@ -92,3 +130,4 @@ vim.api.nvim_create_autocmd('BufEnter', { vim.api.nvim_create_user_command('TrimWhiteSpace', function() vim.cmd('%s/\\s\\+$//e') end, {}) + diff --git a/nvim/keymaps.lua b/nvim/keymaps.lua index 8621537..6d97167 100644 --- a/nvim/keymaps.lua +++ b/nvim/keymaps.lua @@ -15,7 +15,7 @@ vim.keymap.set('n', 's', ':call WindowSwap#EasyWindowSwap()', {}) -- Convenience vim.keymap.set('n', 'w', ':w', { silent = true }) -vim.keymap.set('n', 'F', ':e.', {}) +vim.keymap.set('n', 'F', ':NvimTreeToggle', { noremap = true, silent = true }) vim.keymap.set('n', 'Y', 'y$', {}) -- Telescope diff --git a/nvim/plugins.lua b/nvim/plugins.lua index 74cf673..96a927d 100644 --- a/nvim/plugins.lua +++ b/nvim/plugins.lua @@ -27,7 +27,7 @@ cmp.setup({ [''] = 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. + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ @@ -97,7 +97,6 @@ lspconfig.dockerls.setup({ capabilities = capabilities }) lspconfig.docker_compose_language_service.setup({ capabilities = capabilities }) lspconfig.flow.setup({ capabilities = capabilities }) lspconfig.marksman.setup({ capabilities = capabilities }) -lspconfig.als.setup({ capabilities = capabilities }) lspconfig.sqls.setup({ capabilities = capabilities }) lspconfig.yamlls.setup({ capabilities = capabilities }) lspconfig.nil_ls.setup({ capabilities = capabilities }) @@ -188,3 +187,26 @@ require("copilot").setup({ panel = { enabled = false }, }) require("copilot_cmp").setup() + +vim.g.bullets_enabled_file_types = { + 'markdown', + 'text', + 'gitcommit', + 'scratch' +} + + +require("nvim-tree").setup({ + sort = { + sorter = "case_sensitive", + }, + view = { + width = 30, + }, + renderer = { + group_empty = true, + }, + -- filters = { + -- dotfiles = true, + -- }, +})