From a506ee28ad78ddd06fdb87e3f184f994c1d32a80 Mon Sep 17 00:00:00 2001 From: js0ny Date: Mon, 10 Feb 2025 22:37:58 +0000 Subject: [PATCH] feats: nvim, emacs, shell * nvim: Add copilot completions * nvim: grug-far buffer won't show lualine & winbar now * nvim: remove obsidian.nvim * nvim: luasnip now works * emacs: more keymaps in org-mode * emacs: start customizing leader keys * shell: Add more ls aliases * shell: Add apt alias in fish --- .gitignore | 4 +++ tools/doom/evil.el | 5 +++ tools/doom/init.el | 4 +-- tools/doom/org.el | 4 ++- tools/fish/conf.d/alias.fish | 21 +++++++++++- tools/nvim/lua/config/icons.lua | 1 + tools/nvim/lua/keymaps/cmp_map.lua | 13 +++++++ tools/nvim/lua/keymaps/init.lua | 12 +------ tools/nvim/lua/plugins/completion.lua | 18 +++++++++- tools/nvim/lua/plugins/misc.lua | 38 ++++++++++++++++----- tools/nvim/lua/plugins/mod/lualine/init.lua | 2 +- tools/nvim/lua/plugins/mod/nvim-cmp.lua | 2 +- tools/nvim/lua/plugins/mod/winbar-nvim.lua | 1 + tools/zsh/mod/alias.zsh | 26 +++++++++++--- 14 files changed, 120 insertions(+), 31 deletions(-) create mode 100644 tools/nvim/lua/keymaps/cmp_map.lua diff --git a/.gitignore b/.gitignore index 9411bb9..a6d3409 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,8 @@ common/fzfrc gitconfig +# Lock files lazy-lock.json + +# Emacs +*.elc diff --git a/tools/doom/evil.el b/tools/doom/evil.el index 2132bc8..fe352be 100644 --- a/tools/doom/evil.el +++ b/tools/doom/evil.el @@ -16,3 +16,8 @@ :nvom "C-w e" 'evil-window-up :nvom "C-w i" 'evil-window-right ) + +;; Swap ; and : +(map! :leader + ";" #'execute-extended-command + ":" #'pp-eval-expression) diff --git a/tools/doom/init.el b/tools/doom/init.el index d00b2e2..d65fbb7 100644 --- a/tools/doom/init.el +++ b/tools/doom/init.el @@ -105,7 +105,7 @@ ;;prodigy ; FIXME managing external services & code builders ;;terraform ; infrastructure as code ;;tmux ; an API for interacting with tmux - ;;tree-sitter ; syntax and parsing, sitting in a tree... + tree-sitter ; syntax and parsing, sitting in a tree... ;;upload ; map local to remote projects via ssh/ftp :os @@ -148,7 +148,7 @@ latex ; writing papers in Emacs has never been so fun ;;lean ; for folks with too much to prove ;;ledger ; be audit you can be - ;;lua ; one-based indices? one-based indices + lua ; one-based indices? one-based indices markdown ; writing docs for people to ignore ;;nim ; python + lisp at the speed of c ;;nix ; I hereby declare "nix geht mehr!" diff --git a/tools/doom/org.el b/tools/doom/org.el index 2a698b5..166f94e 100644 --- a/tools/doom/org.el +++ b/tools/doom/org.el @@ -33,7 +33,9 @@ "C-c i" (lambda () (interactive) (my/insert-emphasis-with-zws ?/)) "C-c u" (lambda () (interactive) (my/insert-emphasis-with-zws ?_)) :nvom "N" 'org-next-visible-heading - :nvom "E" 'org-previous-visible-heading) + :nvom "E" 'org-previous-visible-heading + :nvom "M-n" 'org-metadown + :nvom "M-e" 'org-metaup) (setq org-capture-templates '(("t" "Task" entry (file+headline "~/OrgFiles/tasks/inbox.org" "Tasks") diff --git a/tools/fish/conf.d/alias.fish b/tools/fish/conf.d/alias.fish index dd4a69d..9fb59c1 100644 --- a/tools/fish/conf.d/alias.fish +++ b/tools/fish/conf.d/alias.fish @@ -22,11 +22,15 @@ alias sn="sudo nvim -u ~/.config/nvim/init.lua" abbr --add py python3 abbr --add ipy ipython +abbr --add g lazygit + # lsd - modern ls if command -v lsd > /dev/null - alias ls='lsd -A' + alias ls='lsd' abbr --add l 'lsd -lah' abbr --add ll 'lsd -l' + abbr --add la 'lsd -A' + abbr --add l. 'lsd -d .*' abbr --add tree 'ls --tree' else abbr --add l 'ls -lah' @@ -53,6 +57,10 @@ function mt mkdir -p (dirname $argv[1]) && touch $argv[1] end +function mtv + mkdir -p (dirname $argv[1]) && touch $argv[1] && nvim $argv[1] +end + # Use neovide as gVim abbr --add gvi "neovide" @@ -61,6 +69,7 @@ if command -v brew > /dev/null abbr --add brewu "brew upgrade && brew update" abbr --add brewr "brew remove" abbr --add brewc "brew cleanup" + abbr --add brewl "brew list" end if command -v pacman > /dev/null @@ -68,6 +77,7 @@ if command -v pacman > /dev/null abbr --add paci "sudo pacman -S" abbr --add pacr "sudo pacman -R" abbr --add pacu "sudo pacman -Syu" + abbr --add pacl "pacman -Q" if command -v paru > /dev/null abbr --add pacs "paru -Ss" else if command -v yay > /dev/null @@ -77,6 +87,15 @@ if command -v pacman > /dev/null end end +if command -v apt > /dev/null + abbr --add apt "sudo apt" + abbr --add apti "sudo apt install" + abbr --add aptr "sudo apt remove" + abbr --add aptu "sudo apt update && sudo apt upgrade" + abbr --add apts "apt search" + abbr --add aptl "apt list --installed" +end + if test "$TERM" = "xterm-ghostty" -o "$TERM" = "xterm-kitty" abbr --add icat "kitten icat" else if test "$TERM_PROGRAM" = "WezTerm" diff --git a/tools/nvim/lua/config/icons.lua b/tools/nvim/lua/config/icons.lua index 12a634f..31c944b 100644 --- a/tools/nvim/lua/config/icons.lua +++ b/tools/nvim/lua/config/icons.lua @@ -43,6 +43,7 @@ local M = { Event = "", Operator = "󰆕", TypeParameter = "󰅲", + Copilot = "", }, } diff --git a/tools/nvim/lua/keymaps/cmp_map.lua b/tools/nvim/lua/keymaps/cmp_map.lua new file mode 100644 index 0000000..8fbb5fc --- /dev/null +++ b/tools/nvim/lua/keymaps/cmp_map.lua @@ -0,0 +1,13 @@ +--- `map` default for `cmp.mapping` +local map = function(map) + return { + { keys = "", cmd = map.select_next_item(), opts = { desc = "Select next completion item" } }, + { keys = "", cmd = map.select_prev_item(), opts = { desc = "Select previous completion item" } }, + { keys = "", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } }, + { keys = "", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } }, + { keys = "", cmd = map.complete(), opts = { desc = "Trigger completion" } }, + { keys = "", cmd = map.abort(), opts = { desc = "Abort completion" } }, + } +end + +return map diff --git a/tools/nvim/lua/keymaps/init.lua b/tools/nvim/lua/keymaps/init.lua index b75cb58..623215d 100644 --- a/tools/nvim/lua/keymaps/init.lua +++ b/tools/nvim/lua/keymaps/init.lua @@ -20,17 +20,7 @@ utils.set_keymaps(keymaps_modifier) M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin ---- `map` default for `cmp.mapping` -function M.cmp_nvim_keymaps(map) - return { - { keys = "", cmd = map.select_next_item(), opts = { desc = "Select next completion item" } }, - { keys = "", cmd = map.select_prev_item(), opts = { desc = "Select previous completion item" } }, - { keys = "", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } }, - { keys = "", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } }, - { keys = "", cmd = map.complete(), opts = { desc = "Trigger completion" } }, - { keys = "", cmd = map.abort(), opts = { desc = "Abort completion" } }, - } -end +M.cmp_nvim_keymaps = require("keymaps.cmp_map") -- local function set_markdown_keymaps(bufnr) -- local opts = { noremap = true, silent = true, buffer = bufnr } diff --git a/tools/nvim/lua/plugins/completion.lua b/tools/nvim/lua/plugins/completion.lua index 6e77a56..8e4c1ad 100644 --- a/tools/nvim/lua/plugins/completion.lua +++ b/tools/nvim/lua/plugins/completion.lua @@ -1,8 +1,24 @@ return { { import = "plugins.mod.nvim-cmp" }, + { + "saadparwaiz1/cmp_luasnip" + }, { "L3MON4D3/LuaSnip", + build = "make install_jsregexp", + config = function() + require("luasnip.loaders.from_vscode").load_standalone( + { + path = "~/.config/zed/snippets/c.json" } + ) + end, + -- TODO: Remove this, simply delete this will let nvim-cmp not work dependencies = { "rafamadriz/friendly-snippets" }, }, - { "rafamadriz/friendly-snippets" }, + { + "zbirenbaum/copilot-cmp", + config = function() + require("copilot_cmp").setup() + end, + }, } diff --git a/tools/nvim/lua/plugins/misc.lua b/tools/nvim/lua/plugins/misc.lua index 9a7bd8f..fdef0a7 100644 --- a/tools/nvim/lua/plugins/misc.lua +++ b/tools/nvim/lua/plugins/misc.lua @@ -1,15 +1,37 @@ return { { "wakatime/vim-wakatime", lazy = false }, { "voldikss/vim-floaterm" }, - { "CRAG666/betterTerm.nvim", opts = { - position = "bot", - size = 15, - } }, - { "CRAG666/code_runner.nvim", config = true }, - { import = "plugins.mod.obsidian-nvim" }, + { + "CRAG666/betterTerm.nvim", + opts = { + position = "bot", + size = 15, + } + }, + { "CRAG666/code_runner.nvim", config = true }, + -- { import = "plugins.mod.obsidian-nvim" }, { import = "plugins.mod.which-keys-nvim" }, { - "github/copilot.vim", - lazy = false, + "zbirenbaum/copilot.lua", + cmd = "Copilot", + build = ":Copilot auth", + event = "BufReadPost", + opts = { + suggestion = { + enabled = not vim.g.ai_cmp, + auto_trigger = true, + hide_during_completion = vim.g.ai_cmp, + keymap = { + accept = "", + next = "", + prev = "", + }, + }, + panel = { enabled = false }, + filetypes = { + markdown = true, + help = true, + }, + }, }, } diff --git a/tools/nvim/lua/plugins/mod/lualine/init.lua b/tools/nvim/lua/plugins/mod/lualine/init.lua index d7cb9d2..6f8cd0c 100644 --- a/tools/nvim/lua/plugins/mod/lualine/init.lua +++ b/tools/nvim/lua/plugins/mod/lualine/init.lua @@ -14,7 +14,7 @@ Remote | Git Branch | Diagnostics | Command | | MID | | Line:Column | Indent | E local config = { options = { disabled_filetypes = { - statusline = { "NvimTree", "alpha" }, + statusline = { "NvimTree", "alpha", "grug-far" }, }, -- Disable sections and component separators component_separators = { left = "", right = "" }, diff --git a/tools/nvim/lua/plugins/mod/nvim-cmp.lua b/tools/nvim/lua/plugins/mod/nvim-cmp.lua index 834ae8d..a86995c 100644 --- a/tools/nvim/lua/plugins/mod/nvim-cmp.lua +++ b/tools/nvim/lua/plugins/mod/nvim-cmp.lua @@ -47,9 +47,9 @@ return { }, mapping = cmp.mapping.preset.insert(mapped), sources = cmp.config.sources({ + { name = "copilot", priority = 10 }, { name = "nvim_lsp" }, { name = "luasnip" }, - { name = "copilot" }, { name = "lazydev", group_index = 0 }, }, { { name = "buffer" }, diff --git a/tools/nvim/lua/plugins/mod/winbar-nvim.lua b/tools/nvim/lua/plugins/mod/winbar-nvim.lua index 713b9c0..b841aa6 100644 --- a/tools/nvim/lua/plugins/mod/winbar-nvim.lua +++ b/tools/nvim/lua/plugins/mod/winbar-nvim.lua @@ -33,6 +33,7 @@ return { "qf", "floaterm", "orgagenda", + "grug-far" }, }) end, diff --git a/tools/zsh/mod/alias.zsh b/tools/zsh/mod/alias.zsh index 4ce8b5d..1b8bb66 100644 --- a/tools/zsh/mod/alias.zsh +++ b/tools/zsh/mod/alias.zsh @@ -25,14 +25,16 @@ alias python=python3 # Set the default Python version to Python 3 alias py=python alias ipy=ipython -alias reload="source $ZDOTDIR/.zshrc" +alias g=lazygit # lsd - modern ls if command -v lsd > /dev/null; then - alias ls='lsd -A' + alias ls='lsd' alias l='lsd -lah' alias ll='lsd -l' + alias la='lsd -A' + alias l.='lsd -d .*' alias tree='lsd --tree -A' else alias l='ls -lah' @@ -56,6 +58,9 @@ tv(){ mt(){ mkdir -p $(dirname $1) && touch $1 } +mtv(){ + mkdir -p $(dirname $1) && touch $1 && nvim $1 +} alias update="source $DOTFILES/scripts/update.zsh" @@ -65,20 +70,31 @@ if command -v pacman > /dev/null; then alias paci="sudo pacman -S" alias pacr="sudo pacman -R" alias pacu="sudo pacman -Syu" + alias pacl="pacman -Q" + if command -v paru > /dev/null; then + alias pacs="paru -Ss" + elif command -v yay > /dev/null; then + alias pacs="yay -Ss" + else + alias pacs="pacman -Ss" + fi fi if command -v apt > /dev/null; then alias apt="sudo apt" alias apti="sudo apt install" - alias aptu="sudo apt update && sudo apt upgrade" alias aptr="sudo apt remove" + alias aptu="sudo apt update && sudo apt upgrade" + alias apts="apt search" + alias aptl="apt list --installed" fi if command -v brew > /dev/null; then alias brewi="brew install" - alias brewu="brew update && brew upgrade" - alias brewc="brew cleanup" alias brewr="brew uninstall" + alias brewu="brew update && brew upgrade" + alias brews="brew search" + alias brewl="brew list" fi