From aa62e1f27b0cb3d712d6f2b13071cca0f09379be Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Thu, 11 Sep 2025 16:38:11 +0100 Subject: Add a lot of changes --- home/.config/alacritty/alacritty.toml | 72 ++- home/.config/ccache/ccache.conf | 1 + home/.config/clangd/config.yaml | 6 + home/.config/fd/ignore | 1 + home/.config/gdb/gdbinit | 6 +- home/.config/git/config | 17 +- home/.config/git/ignore | 573 +-------------------- home/.config/htop/htoprc | 7 +- home/.config/nvim/after/ftplugin/c.lua | 1 - home/.config/nvim/after/ftplugin/cfg.lua | 3 - home/.config/nvim/after/ftplugin/cpp.lua | 2 - home/.config/nvim/after/ftplugin/dosini.lua | 3 - home/.config/nvim/after/ftplugin/gitcommit.lua | 2 - home/.config/nvim/after/ftplugin/gitrebase.lua | 29 +- home/.config/nvim/after/ftplugin/help.lua | 3 - home/.config/nvim/after/ftplugin/json.lua | 1 - home/.config/nvim/after/ftplugin/mail.lua | 1 - home/.config/nvim/after/ftplugin/markdown.lua | 1 - home/.config/nvim/after/ftplugin/sxhkdrc.lua | 10 + home/.config/nvim/after/ftplugin/tex.lua | 4 - home/.config/nvim/after/ftplugin/text.lua | 2 - home/.config/nvim/after/ftplugin/tmux.lua | 1 - home/.config/nvim/after/ftplugin/xdefaults.lua | 11 +- home/.config/nvim/after/plugin/autocmds.lua | 288 +++++++---- home/.config/nvim/after/plugin/mappings.lua | 176 +++++-- home/.config/nvim/filetype.lua | 7 + home/.config/nvim/init.lua | 28 +- home/.config/nvim/lsp/clangd.lua | 57 ++ home/.config/nvim/lsp/lua_ls.lua | 9 + home/.config/nvim/lua/cfg/options.lua | 66 ++- home/.config/nvim/lua/cfg/utils.lua | 12 +- .../.config/nvim/lua/custom/plugins/completion.lua | 188 +++---- home/.config/nvim/lua/custom/plugins/debug.lua | 360 ++++++------- home/.config/nvim/lua/custom/plugins/ft.lua | 7 - home/.config/nvim/lua/custom/plugins/git.lua | 166 +++--- home/.config/nvim/lua/custom/plugins/init.lua | 467 ++++++++++++++++- home/.config/nvim/lua/custom/plugins/lsp.lua | 387 +++++++------- home/.config/nvim/lua/custom/plugins/telescope.lua | 397 ++++++++++---- home/.config/nvim/lua/custom/plugins/ts.lua | 292 +++++------ home/.config/nvim/lua/custom/plugins/ui.lua | 75 +-- home/.config/nvim/lua/mapper.lua | 84 --- home/.config/pacman/makepkg.conf | 2 +- home/.config/pam-gnupg | 13 +- home/.config/sh/aliases | 5 +- home/.config/sh/envrc | 74 ++- home/.config/sxhkd/sxhkdrc | 6 +- home/.config/tmux/tmux.conf | 50 +- home/.config/zsh/.zshrc | 29 +- 48 files changed, 2175 insertions(+), 1827 deletions(-) create mode 100644 home/.config/fd/ignore delete mode 120000 home/.config/nvim/after/ftplugin/c.lua delete mode 100644 home/.config/nvim/after/ftplugin/cfg.lua delete mode 100644 home/.config/nvim/after/ftplugin/cpp.lua delete mode 100644 home/.config/nvim/after/ftplugin/dosini.lua delete mode 100644 home/.config/nvim/after/ftplugin/help.lua delete mode 100644 home/.config/nvim/after/ftplugin/json.lua create mode 100644 home/.config/nvim/after/ftplugin/sxhkdrc.lua delete mode 100644 home/.config/nvim/after/ftplugin/tex.lua delete mode 100644 home/.config/nvim/after/ftplugin/tmux.lua create mode 100644 home/.config/nvim/lsp/clangd.lua create mode 100644 home/.config/nvim/lsp/lua_ls.lua delete mode 100644 home/.config/nvim/lua/custom/plugins/ft.lua delete mode 100644 home/.config/nvim/lua/mapper.lua (limited to 'home/.config') diff --git a/home/.config/alacritty/alacritty.toml b/home/.config/alacritty/alacritty.toml index 54ffe03..a08219b 100644 --- a/home/.config/alacritty/alacritty.toml +++ b/home/.config/alacritty/alacritty.toml @@ -1,29 +1,34 @@ [general] live_config_reload = false -[colors.bright] -black = "0x928374" -blue = "0x83a598" -cyan = "0x8ec07c" -green = "0xb8bb26" -magenta = "0xd3869b" -red = "0xfb4934" -white = "0xebdbb2" -yellow = "0xfabd2f" +# Default colors +[colors.primary] +# hard contrast background = = '#1d2021' +background = '#282828' +# soft contrast background = = '#32302f' +foreground = '#ebdbb2' +# Normal colors [colors.normal] -black = "0x282828" -blue = "0x458588" -cyan = "0x689d6a" -green = "0x98971a" -magenta = "0xb16286" -red = "0xcc241d" -white = "0xa89984" -yellow = "0xd79921" +black = '#282828' +red = '#cc241d' +green = '#98971a' +yellow = '#d79921' +blue = '#458588' +magenta = '#b16286' +cyan = '#689d6a' +white = '#a89984' -[colors.primary] -background = "0x1d2021" -foreground = "0xebdbb2" +# Bright colors +[colors.bright] +black = '#928374' +red = '#fb4934' +green = '#b8bb26' +yellow = '#fabd2f' +blue = '#83a598' +magenta = '#d3869b' +cyan = '#8ec07c' +white = '#ebdbb2' [cursor] blink_interval = 500 @@ -69,3 +74,30 @@ mods = "Alt" action = "ScrollToBottom" key = "G" mods = "Alt|Shift" + +[[hints.enabled]] +command = "xdg-open" +hyperlinks = true +post_processing = true +persist = false +mouse.enabled = true +binding = { key = "O", mods = "Control|Shift" } +regex = "(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://)[^\u0000-\u001F\u007F-\u009F<>\"\\s{-}\\^⟨⟩‘\\\\]+" + +[[hints.enabled]] +regex = " /[0-9a-zA-Z/\\-_\\.]+(:\\d*){0,2}" +command.program = "linkhandler" +post_processing = true +mouse.enabled = true + +[[hints.enabled]] +regex = "^/[0-9a-zA-Z/\\-_\\.]+(:\\d*){0,2}" +command.program = "linkhandler" +post_processing = true +mouse.enabled = true + +[[hints.enabled]] +regex = "[0-9a-zA-Z/\\-_\\.]+:(\\d+)(:\\d*)?" +command.program = "linkhandler" +post_processing = true +mouse.enabled = true diff --git a/home/.config/ccache/ccache.conf b/home/.config/ccache/ccache.conf index 4406ae5..99d2c37 100644 --- a/home/.config/ccache/ccache.conf +++ b/home/.config/ccache/ccache.conf @@ -1 +1,2 @@ max_size = 0 +reshare = true diff --git a/home/.config/clangd/config.yaml b/home/.config/clangd/config.yaml index 06844c8..6558d1d 100644 --- a/home/.config/clangd/config.yaml +++ b/home/.config/clangd/config.yaml @@ -1,10 +1,16 @@ +--- Index: StandardLibrary: Yes Diagnostics: ClangTidy: FastCheckFilter: None + UnusedIncludes: Strict + # MissingIncludes: Strict + Includes: + AnalyzeAngledIncludes: Yes InlayHints: Enabled: Yes BlockEnd: Yes + DefaultArguments: Yes Hover: ShowAKA: Yes diff --git a/home/.config/fd/ignore b/home/.config/fd/ignore new file mode 100644 index 0000000..2d2ecd6 --- /dev/null +++ b/home/.config/fd/ignore @@ -0,0 +1 @@ +.git/ diff --git a/home/.config/gdb/gdbinit b/home/.config/gdb/gdbinit index b85d4f8..20fd024 100644 --- a/home/.config/gdb/gdbinit +++ b/home/.config/gdb/gdbinit @@ -1,5 +1,5 @@ set debuginfod enabled on -set logging enabled on -set logging file /tmp/trace.log -thread apply all backtrace full set confirm off +set print pretty on +set follow-fork-mode child +set auto-load local-gdbinit on diff --git a/home/.config/git/config b/home/.config/git/config index e1befe1..4649d7b 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -12,11 +12,9 @@ pager = delta [branch] sort=-committerdate -[web] - browser = librewolf [diff] tool = nvimdiff - algorithm = histogram + # algorithm = histogram colorMoved = default mnemonicPrefix = true relative = true @@ -32,6 +30,7 @@ cmd = difft "$MERGED" "$LOCAL" "abcdef1" "100644" "$REMOTE" "abcdef2" "100644" [rebase] autoStash = true + autoSquash = true [fetch] recurseSubmodules = on-demand prune = true @@ -44,7 +43,7 @@ name = mergiraf driver = mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P [mergetool] - keepTemporaries = false + keepBackup = false [mergetool "conflictmarker"] cmd = $EDITOR "$MERGED" [commit] @@ -61,8 +60,6 @@ [interactive] singleKey = true diffFilter = delta --color-only -[format] - signOff = true [advice] detachedHead = false skippedCherryPicks = false @@ -70,10 +67,12 @@ navigate = true features = gruvmax-fang zebra-dark dark = true - #side-by-side = true + side-by-side = true line-numbers = true relative-paths = true hyperlinks = true +[absorb] + autoStageIfNothingStaged = true [alias] cl = clone br = branch -vv @@ -127,7 +126,9 @@ dl = -c diff.external=difft log -p --ext-diff ds = -c diff.external=difft show --ext-diff dft = -c diff.external=difft diff -[includeIf "gitdir:/devspace/"] +[includeIf "gitdir:/home/*/work/"] path = config-work [includeIf "gitdir:~/doxfiles/.git"] path = config-personal +[includeIf "gitdir:~/personal/"] + path = config-personal diff --git a/home/.config/git/ignore b/home/.config/git/ignore index fef5cc0..ff3b20a 100644 --- a/home/.config/git/ignore +++ b/home/.config/git/ignore @@ -1,561 +1,22 @@ -# perf -perf.data* - -# Vim -.exrc -.doit.lua -.luarc.json - -# Swap -[._]*.s[a-v][a-z] -[._]*.sw[a-p] -[._]s[a-rt-v][a-z] -[._]ss[a-gi-z] -[._]sw[a-p] - -# Session -Session.vim - -# Temporary -.netrwhist -*~ -# Auto-generated tag files -tags -tags.* -# Persistent undo -[._]*.un~ - -# Tags -# Ignore tags created by etags, ctags, gtags (GNU global) and cscope -TAGS -.TAGS -tags -.tags -gtags.files -GTAGS -GRTAGS -GPATH -GSYMS -cscope.files -cscope.out -cscope.in.out -cscope.po.out - -# C++ - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files *.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.out -*.app - -# C - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -# *.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf - -# archive files - -# It's better to unpack these files and commit the raw source because -# git has its own built in compression methods. -*.7z -*.jar -*.rar +*.tar.gz +*.tar.zst *.zip -*.gz -*.tgz -*.bzip -*.bz2 -*.xz -*.lzma -*.cab - -# Packing-only formats -*.iso -*.tar - -# Package management formats -*.dmg -*.xpi -*.gem -*.egg -*.deb -*.rpm -*.msi -*.msm -*.msp - -# Diff -*.patch -*.diff - -# Clion -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/ - -# CMake -cmake-build-*/ +*/.cache/clangd/index/ +*/node_modules/ +.SRCINFO +.cache/clangd/index/ +.env/ +.venv/ +__pycache__/ build*/ -build -build-release -build-reldbg - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Linux -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -# LibreOffice locks -.~lock.*# - -# backup -*.bak -*.gho -*.ori -*.tmp - -# Cmake -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -# Makefile -cmake_install.cmake -install_manifest.txt compile_commands.json -CTestTestfile.cmake - -# CUDA -*.i -*.ii -*.gpu -*.ptx -*.cubin -*.fatbin - -# Python -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -# lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -# profile_default/ -# ipython_config.py - -# pyenv -.python-version - -# Environments -.env -.venv -# env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Latex -## Core latex/pdflatex auxiliary files: -*.aux -*.lof -*.log -*.lot -*.fls -*.out -*.toc -*.fmt -*.fot -*.cb -*.cb2 -.*.lb - -## Intermediate documents: -*.dvi -*.xdv -*-converted-to.* -# these rules might exclude image files for figures etc. -# *.ps -# *.eps -# *.pdf - -## Generated if empty string is given at "Please type another file name for output:" -.pdf - -## Bibliography auxiliary files (bibtex/biblatex/biber): -*.bbl -*.bcf -*.blg -*-blx.aux -*-blx.bib -*.run.xml - -## Build tool auxiliary files: -*.fdb_latexmk -*.synctex -*.synctex(busy) -*.synctex.gz -*.synctex.gz(busy) -*.pdfsync - -## Build tool directories for auxiliary files -# latexrun -latex.out/ - -## Auxiliary and intermediate files from other packages: -# algorithms -*.alg -*.loa - -# achemso -acs-*.bib - -# amsthm -*.thm - -# beamer -*.nav -*.pre -*.snm -*.vrb - -# changes -*.soc - -# comment -*.cut - -# cprotect -*.cpt - -# elsarticle (documentclass of Elsevier journals) -*.spl - -# endnotes -*.ent - -# fixme -*.lox - -# feynmf/feynmp -*.mf -*.mp -*.t[1-9] -*.t[1-9][0-9] -*.tfm - -# glossaries -*.acn -*.acr -*.glg -*.glo -*.gls -*.glsdefs - -# gnuplottex -*-gnuplottex-* - -# gregoriotex -*.gaux -*.gtex - -# htlatex -*.4ct -*.4tc -*.idv -*.lg -*.trc -*.xref - -# hyperref -*.brf - -# knitr -*-concordance.tex -# TODO Comment the next line if you want to keep your tikz graphics files -*.tikz -*-tikzDictionary - -# listings -*.lol - -# makeidx -*.idx -*.ilg -*.ind -*.ist - -# minitoc -*.maf -*.mlf -*.mlt -*.mtc[0-9]* -*.slf[0-9]* -*.slt[0-9]* -*.stc[0-9]* - -# minted -_minted* -*.pyg - -# morewrites -*.mw - -# nomencl -*.nlg -*.nlo -*.nls - -# pax -*.pax - -# pdfpcnotes -*.pdfpc - -# sagetex -*.sagetex.sage -*.sagetex.py -*.sagetex.scmd - -# scrwfile -*.wrt - -# sympy -*.sout -*.sympy -sympy-plots-for-*.tex/ - -# pdfcomment -*.upa -*.upb - -# pythontex -*.pytxcode -pythontex-files-*/ - -# tcolorbox -*.listing - -# thmtools -*.loe - -# TikZ & PGF -*.dpth -*.md5 -*.auxlock - -# todonotes -*.tdo - -# vhistory -*.hst -*.ver - -# easy-todo -*.lod - -# xcolor -*.xcp - -# xmpincl -*.xmpi - -# xindy -*.xdy - -# xypic precompiled matrices -*.xyc - -# endfloat -*.ttt -*.fff - -## Editors: -# WinEdt -*.bak -*.sav - -# Kile -*.backup - -# KBibTeX -*~[0-9]* - -# auto folder when using emacs and auctex -./auto/* -*.el - -# expex forward references with \gathertags -*-tags.tex - -# standalone packages -*.sta - -# ccls -.ccls-cache - -# clangd -.clangd - -# pkgs - -.SRCINFO -*.tar.gz -*.zip -*.tar.zst - +env/ node_modules/ +venv/ +.gdbinit +.lldbinit +.nvim.lua +.nvim/ +.ignore +tablegen_compile_commands.yml diff --git a/home/.config/htop/htoprc b/home/.config/htop/htoprc index 2bb5f42..50a041f 100644 --- a/home/.config/htop/htoprc +++ b/home/.config/htop/htoprc @@ -1,6 +1,6 @@ # Beware! This file is rewritten by htop when settings are changed in the interface. # The parser is also very primitive, and not human-friendly. -htop_version=3.3.0 +htop_version=3.4.1-3.4.1 config_reader_min_version=3 fields=0 17 18 20 48 2 50 113 46 47 39 1 hide_kernel_threads=1 @@ -27,6 +27,7 @@ show_cpu_usage=1 show_cpu_frequency=1 show_cpu_temperature=1 degree_fahrenheit=0 +show_cached_memory=1 update_process_names=1 account_guest_in_cpu_meter=1 color_scheme=5 @@ -38,7 +39,7 @@ column_meters_0=Uptime Systemd Tasks LoadAverage Load CPU AllCPUs2 CPU column_meter_modes_0=2 2 2 1 3 1 1 3 column_meters_1=Memory Swap Memory DiskIO DiskIO NetworkIO NetworkIO column_meter_modes_1=1 2 3 2 3 2 3 -tree_view=0 +tree_view=1 sort_key=46 tree_sort_key=0 sort_direction=-1 @@ -49,7 +50,7 @@ screen:Main=PID PRIORITY NICE STARTTIME USER STATE NLWP OOM PERCENT_CPU PERCENT_ .sort_key=PERCENT_CPU .tree_sort_key=PID .tree_view_always_by_pid=0 -.tree_view=0 +.tree_view=1 .sort_direction=-1 .tree_sort_direction=1 .all_branches_collapsed=0 diff --git a/home/.config/nvim/after/ftplugin/c.lua b/home/.config/nvim/after/ftplugin/c.lua deleted file mode 120000 index 48a225a..0000000 --- a/home/.config/nvim/after/ftplugin/c.lua +++ /dev/null @@ -1 +0,0 @@ -cpp.lua \ No newline at end of file diff --git a/home/.config/nvim/after/ftplugin/cfg.lua b/home/.config/nvim/after/ftplugin/cfg.lua deleted file mode 100644 index 3e79acd..0000000 --- a/home/.config/nvim/after/ftplugin/cfg.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.bo.commentstring = "// %s" - -vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "| setlocal commentstring<" diff --git a/home/.config/nvim/after/ftplugin/cpp.lua b/home/.config/nvim/after/ftplugin/cpp.lua deleted file mode 100644 index e3d3a8c..0000000 --- a/home/.config/nvim/after/ftplugin/cpp.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.bo.commentstring = "// %s" -vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "| setlocal commentstring<" diff --git a/home/.config/nvim/after/ftplugin/dosini.lua b/home/.config/nvim/after/ftplugin/dosini.lua deleted file mode 100644 index f6d7437..0000000 --- a/home/.config/nvim/after/ftplugin/dosini.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.bo.commentstring = "# %s" -vim.b.undo_ftplugin = vim.b.undo_ftplugin - .. "|setlocal commentstring" diff --git a/home/.config/nvim/after/ftplugin/gitcommit.lua b/home/.config/nvim/after/ftplugin/gitcommit.lua index 8525714..9095ee4 100644 --- a/home/.config/nvim/after/ftplugin/gitcommit.lua +++ b/home/.config/nvim/after/ftplugin/gitcommit.lua @@ -1,5 +1,3 @@ vim.wo.spell = true vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "|setlocal spell<" vim.cmd([[match ErrorMsg /\%1l.\%>50v/]]) -local bufnr = vim.api.nvim_buf_get_number(0) -require("mapper").ncmd("gd", "DiffGitCached", nil, bufnr) diff --git a/home/.config/nvim/after/ftplugin/gitrebase.lua b/home/.config/nvim/after/ftplugin/gitrebase.lua index 38a2153..0fc4102 100644 --- a/home/.config/nvim/after/ftplugin/gitrebase.lua +++ b/home/.config/nvim/after/ftplugin/gitrebase.lua @@ -1,20 +1,11 @@ -local map = require("mapper") -local ncmd = map.ncmd -local vcmd = map.vcmd -local bufnr = 0 +local function nvmap(l, r, desc) + vim.keymap.set({ "n", "v" }, l, r, { buffer = 0, desc = desc }) +end -ncmd("gc", "Cycle", nil, bufnr) -ncmd("gp", "Pick", nil, bufnr) -ncmd("ge", "Edit", nil, bufnr) -ncmd("gf", "Fixup", nil, bufnr) -ncmd("gd", "Drop", nil, bufnr) -ncmd("gs", "Squash", nil, bufnr) -ncmd("gr", "Reword", nil, bufnr) - -vcmd("gc", "Cycle", nil, bufnr) -vcmd("gp", "Pick", nil, bufnr) -vcmd("ge", "Edit", nil, bufnr) -vcmd("gf", "Fixup", nil, bufnr) -vcmd("gd", "Drop", nil, bufnr) -vcmd("gs", "Squash", nil, bufnr) -vcmd("gr", "Reword", nil, bufnr) +nvmap("gc", "Cycle", "[C]ycle") +nvmap("gp", "Pick", "[P]ick") +nvmap("ge", "Edit", "[E]dit") +nvmap("gf", "Fixup", "[F]ixup") +nvmap("gd", "Drop", "[D]rop") +nvmap("gs", "Squash", "[S]quash") +nvmap("gr", "Reword", "[R]eword") diff --git a/home/.config/nvim/after/ftplugin/help.lua b/home/.config/nvim/after/ftplugin/help.lua deleted file mode 100644 index 63147a6..0000000 --- a/home/.config/nvim/after/ftplugin/help.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.keymap.set("n", "q", function() - vim.api.nvim_win_close(0, false) -end, { buffer = true }) diff --git a/home/.config/nvim/after/ftplugin/json.lua b/home/.config/nvim/after/ftplugin/json.lua deleted file mode 100644 index 726acd0..0000000 --- a/home/.config/nvim/after/ftplugin/json.lua +++ /dev/null @@ -1 +0,0 @@ -vim.cmd([[syntax match Comment +\/\/.\+$+]]) diff --git a/home/.config/nvim/after/ftplugin/mail.lua b/home/.config/nvim/after/ftplugin/mail.lua index 538c10b..9fe1500 100644 --- a/home/.config/nvim/after/ftplugin/mail.lua +++ b/home/.config/nvim/after/ftplugin/mail.lua @@ -1,2 +1 @@ vim.wo.spell = true -vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "|setlocal spell<" diff --git a/home/.config/nvim/after/ftplugin/markdown.lua b/home/.config/nvim/after/ftplugin/markdown.lua index 538c10b..9fe1500 100644 --- a/home/.config/nvim/after/ftplugin/markdown.lua +++ b/home/.config/nvim/after/ftplugin/markdown.lua @@ -1,2 +1 @@ vim.wo.spell = true -vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "|setlocal spell<" diff --git a/home/.config/nvim/after/ftplugin/sxhkdrc.lua b/home/.config/nvim/after/ftplugin/sxhkdrc.lua new file mode 100644 index 0000000..327c5a0 --- /dev/null +++ b/home/.config/nvim/after/ftplugin/sxhkdrc.lua @@ -0,0 +1,10 @@ +vim.bo.commentstring = "# %s" + +vim.api.nvim_create_autocmd( + "BufWritePost", + { + group = vim.api.nvim_create_augroup("sxhkd", { clear = true }), + buffer = 0, + command = "!pkill --signal SIGUSR1 sxhkd", + } +) diff --git a/home/.config/nvim/after/ftplugin/tex.lua b/home/.config/nvim/after/ftplugin/tex.lua deleted file mode 100644 index b1dbce0..0000000 --- a/home/.config/nvim/after/ftplugin/tex.lua +++ /dev/null @@ -1,4 +0,0 @@ -vim.wo.spell = true -vim.bo.formatoptions = vim.bo.formatoptions .. "t" -vim.b.undo_ftplugin = vim.b.undo_ftplugin - .. "|setlocal spell< |setlocal formatoptions<" diff --git a/home/.config/nvim/after/ftplugin/text.lua b/home/.config/nvim/after/ftplugin/text.lua index 8c72f6f..2179c42 100644 --- a/home/.config/nvim/after/ftplugin/text.lua +++ b/home/.config/nvim/after/ftplugin/text.lua @@ -1,5 +1,3 @@ vim.wo.spell = true vim.bo.formatoptions = vim.bo.formatoptions .. "t" vim.bo.commentstring = "# %s" -vim.b.undo_ftplugin = vim.b.undo_ftplugin - .. "|setlocal spell< |setlocal formatoptions< |setlocal commentstring" diff --git a/home/.config/nvim/after/ftplugin/tmux.lua b/home/.config/nvim/after/ftplugin/tmux.lua deleted file mode 100644 index 590a12e..0000000 --- a/home/.config/nvim/after/ftplugin/tmux.lua +++ /dev/null @@ -1 +0,0 @@ -vim.api.nvim_create_autocmd("BufWritePost", { buffer = 0, command = "make" }) diff --git a/home/.config/nvim/after/ftplugin/xdefaults.lua b/home/.config/nvim/after/ftplugin/xdefaults.lua index 0f4ec99..09dbce3 100644 --- a/home/.config/nvim/after/ftplugin/xdefaults.lua +++ b/home/.config/nvim/after/ftplugin/xdefaults.lua @@ -1,9 +1,10 @@ vim.bo.commentstring = "! %s" -vim.api.nvim_create_augroup("xdefaults", {}) + vim.api.nvim_create_autocmd( "BufWritePost", - { group = "xdefaults", buffer = 0, command = "!xrdb %" } + { + group = vim.api.nvim_create_augroup("xdefaults", { clear = true }), + buffer = 0, + command = "!xrdb %", + } ) - -vim.b.undo_ftplugin = vim.b.undo_ftplugin - .. "| setlocal commentstring< diff --git a/home/.config/nvim/after/plugin/autocmds.lua b/home/.config/nvim/after/plugin/autocmds.lua index 7ab937f..22cf732 100644 --- a/home/.config/nvim/after/plugin/autocmds.lua +++ b/home/.config/nvim/after/plugin/autocmds.lua @@ -1,137 +1,229 @@ local function augroup(name) - return vim.api.nvim_create_augroup(name, {}) + return vim.api.nvim_create_augroup(name, { clear = true }) end local autocmd = vim.api.nvim_create_autocmd --- adapted from https://github.com/ethanholz/nvim-lastplace/blob/main/lua/nvim-lastplace/init.lua -local ignore_buftype = { "quickfix", "nofile", "help" } -local ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" } - -local function run() - if vim.tbl_contains(ignore_buftype, vim.bo.buftype) then - return - end - - if vim.tbl_contains(ignore_filetype, vim.bo.filetype) then - -- reset cursor to first line - vim.cmd [[normal! gg]] - return - end - - -- If a line has already been specified on the command line, we are done - -- nvim file +num - if vim.fn.line(".") > 1 then - return - end - - local last_line = vim.fn.line([['"]]) - local buff_last_line = vim.fn.line("$") - - -- If the last line is set and the less than the last line in the buffer - if last_line > 0 and last_line <= buff_last_line then - local win_last_line = vim.fn.line("w$") - local win_first_line = vim.fn.line("w0") - -- Check if the last line of the buffer is the same as the win - if win_last_line == buff_last_line then - -- Set line to last line edited - vim.cmd [[normal! g`"]] - -- Try to center - elseif buff_last_line - last_line > - ((win_last_line - win_first_line) / 2) - 1 then - vim.cmd [[normal! g`"zz]] - else - vim.cmd [[normal! G'"]] +-- Check if we need to reload the file when it changed +autocmd({ "FocusGained", "TermClose", "TermLeave" }, { + group = augroup("checktime"), + callback = function() + if vim.o.buftype ~= "nofile" then + vim.cmd("checktime") end - end -end + end, +}) -augroup("restore position") +-- Highlight on yank +autocmd("TextYankPost", { + group = augroup("highlight_yank"), + callback = vim.hl.on_yank, +}) + +-- go to last loc when opening a buffer autocmd("BufReadPost", { - once = true, - group = "restore position", - callback = run + group = augroup("last_loc"), + callback = function(event) + local exclude = { "gitcommit" } + local buf = event.buf + if + vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].last_loc + then + return + end + vim.b[buf].last_loc = true + local mark = vim.api.nvim_buf_get_mark(buf, '"') + local lcount = vim.api.nvim_buf_line_count(buf) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, }) -augroup("postwrite") -autocmd("BufWritePost", { - group = "postwrite", - pattern = ".Xkeymap", - command = "!xkbcomp % $DISPLAY", +-- close some filetypes with +autocmd("FileType", { + group = augroup("close_with_q"), + pattern = { + "PlenaryTestPopup", + "checkhealth", + "dbout", + "gitsigns-blame", + "grug-far", + "help", + "lspinfo", + "neotest-output", + "neotest-output-panel", + "neotest-summary", + "notify", + "qf", + "spectre_panel", + "startuptime", + "tsplayground", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.schedule(function() + vim.keymap.set("n", "q", function() + vim.cmd("close") + pcall(vim.api.nvim_buf_delete, event.buf, { force = true }) + end, { + buffer = event.buf, + silent = true, + desc = "Quit buffer", + }) + end) + end, +}) + +-- make it easier to close man-files when opened inline +autocmd("FileType", { + group = augroup("man_unlisted"), + pattern = { "man" }, + callback = function(event) + vim.bo[event.buf].buflisted = false + end, +}) + +-- Auto create dir when saving a file, in case some intermediate directory does not exist +autocmd({ "BufWritePre" }, { + group = augroup("auto_create_dir"), + callback = function(event) + if event.match:match("^%w%w+:[\\/][\\/]") then + return + end + local file = vim.uv.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") + end, }) + autocmd("BufWritePost", { - group = "postwrite", + group = augroup("bspwm"), pattern = "*bspwmrc", command = "!bspc wm --restart", }) autocmd("BufWritePost", { - group = "postwrite", + group = augroup("polybar"), pattern = "*/polybar/config", command = "!polybar-msg cmd restart", }) autocmd("BufWritePost", { - group = "postwrite", + group = augroup("xdg-user-dirs"), pattern = "user-dirs.dirs,user-dirs.locale", command = "!xdg-user-dirs-update", }) autocmd("BufWritePost", { - group = "postwrite", - pattern = "plugins.lua", - command = "source % | PackerSync", -}) -autocmd("BufWritePost", { - group = "postwrite", + group = augroup("dunst"), pattern = "dunstrc", command = "!killall -SIGUSR2 dunst", }) -autocmd( - "BufWritePost", - { group = "postwrite", pattern = "fonts.conf", command = "!fc-cache" } -) - -augroup("autocomplete") -autocmd("CompleteDone", { - group = "autocomplete", - command = "if pumvisible() == 0 | silent! pclose | endif", +autocmd("BufWritePost", { + group = augroup("fc-cache"), + pattern = "fonts.conf", + command = "!fc-cache", }) -augroup("reload") -autocmd("CompleteDone", { - group = "reload", - command = "if getcmdwintype() == '' | checktime | endif", -}) +autocmd("LspAttach", { + group = augroup("lsp-attach"), + callback = function(event) + local bufnr = event.buf -augroup("highlightyank") -autocmd( - "TextYankPost", - { group = "highlightyank", callback = vim.highlight.on_yank } -) + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc }) + end + local function nmap(l, r, desc) + map("n", l, r, desc) + end + local function nvmap(l, r, desc) + map({ "n", "v" }, l, r, desc) + end + nmap("", vim.lsp.buf.definition, "Goto definition") + nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + nvmap("gra", vim.lsp.buf.code_action, "[R]un code [A]ction") -augroup("quitro") -autocmd("BufReadPost", { - group = "quitro", - callback = function() - if vim.opt.readonly:get() then - vim.keymap.set("n", "q", "q") + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if + client + and client:supports_method( + vim.lsp.protocol.Methods.textDocument_documentHighlight, + event.buf + ) + then + local highlight_augroup = + vim.api.nvim_create_augroup("lsp-highlight", { clear = false }) + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd("LspDetach", { + group = vim.api.nvim_create_augroup("lsp-detach", { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds({ + group = "lsp-highlight", + buffer = event2.buf, + }) + end, + }) + end + + if + client + and client:supports_method( + vim.lsp.protocol.Methods.textDocument_codeLens, + event.buf + ) + then + vim.api.nvim_create_autocmd( + { "CursorHold", "CursorHoldI", "InsertLeave" }, + { + buffer = bufnr, + group = vim.api.nvim_create_augroup("codelens", { clear = true }), + callback = vim.lsp.codelens.refresh, + } + ) + nmap("cl", vim.lsp.codelens.run, "Run [C]ode [L]ens") + end + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if + client + and client:supports_method( + vim.lsp.protocol.Methods.textDocument_inlayHint, + event.buf + ) + then + nmap("th", function() + vim.lsp.inlay_hint.enable( + not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }) + ) + end, "[T]oggle Inlay [H]ints") end end, }) -augroup("localinit") -autocmd("VimEnter", { - group = "localinit", +autocmd("FileType", { + group = augroup("treesitter_start"), + pattern = { "*" }, callback = function() - local settings = vim.fn.findfile(".doit.lua", ".;") - if settings ~= "" then - print("sourcing local config") - dofile(settings) + if pcall(vim.treesitter.start) then + -- vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end end, }) - -augroup("restore guicursor") -autocmd("VimLeave", { - once = true, - group = "restore guicursor", - command = 'set guicursor= | call chansend(v:stderr, "\x1b[ q")' -}) diff --git a/home/.config/nvim/after/plugin/mappings.lua b/home/.config/nvim/after/plugin/mappings.lua index a2fb6cd..9eeaf19 100644 --- a/home/.config/nvim/after/plugin/mappings.lua +++ b/home/.config/nvim/after/plugin/mappings.lua @@ -1,22 +1,48 @@ -local map = require("mapper") +local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { desc = desc }) +end +local function cmd(mode, l, r, desc) + map(mode, l, "" .. r .. "", desc) +end +local function cmdi(mode, l, r, desc) + map(mode, l, ":" .. r, desc) +end +local function nmap(l, r, desc) + map("n", l, r, desc) +end +local function vmap(l, r, desc) + map("v", l, r, desc) +end +local function nvmap(l, r, desc) + map({ "n", "v" }, l, r, desc) +end +local function ncmd(l, r, desc) + cmd("n", l, r, desc) +end +local function ncmdi(l, r, desc) + cmdi("n", l, r, desc) +end +local function vcmdi(l, r, desc) + cmdi("v", l, r, desc) +end -map.n("", "") +ncmd("", "nohlsearch") + +nmap("", "") -- make an accidental ; press also enter command mode -- temporarily disabled to to vim-sneak plugin -map.n(";", ":") +nmap(";", ":") -- highlight last inserted text -map.n("gV", "`[v`]") +nmap("gV", "`[v`]") -map.n("", "") -map.n("", "") +nmap("", "") +nmap("", "") -- go to first non-blank character of current line -map.n("", "^") -map.v("", "^") -map.n("", "$") -map.v("", "$") +nvmap("", "^") +nvmap("", "$") -- This extends p in visual mode (note the noremap), so that if you paste from -- the unnamed (ie. default) register, that register content is not replaced by @@ -24,36 +50,108 @@ map.v("", "$") -- This enables the user to yank some text and paste it over several places in -- a row, without using a named register -- map.v('p', "p:if v:register == '"'let @@=@0endif") -map.v("p", 'p:let @+=@0:let @"=@0') - -map.v("p", '"_dP') -map.n("d", '"_d') -map.n("D", '"_D') -map.map("", "c", '"_c') -map.map("", "C", '"_C') +vmap("p", 'p:let @+=@0:let @"=@0') -- Find and Replace binds -map.ncmdi("s", "%s/") -map.vcmdi("s", "s/") -map.ncmdi("gs", '%s/"/') -map.vcmdi("gs", 's/"/') -map.ncmdi("S", "%s//") - -map.ncmd("x", "wall") -map.ncmd("z", "wqall") -map.ncmd("q", "quitall") -map.ncmd("x", "update") - -map.n("", "h") -map.n("", "j") -map.n("", "k") -map.n("", "l") - -map.t("", "", { silent = true, noremap = true, expr = true }) - -map.n("[w", function() - vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR }) +ncmdi("s", "%s/") +vcmdi("s", "s/") + +ncmd("x", "wall") +ncmd("z", "wqall") +ncmd("q", "quitall") + +vim.keymap.set( + "t", + "", + "", + { silent = true, noremap = true, expr = true, desc = "Exit terminal mode" } +) + +nmap("[w", function() + vim.diagnostic.jump({ + count = -vim.v.count1, + severity = { min = vim.diagnostic.severity.WARN }, + }) +end) +nmap("]w", function() + vim.diagnostic.jump({ + count = vim.v.count1, + severity = { min = vim.diagnostic.severity.WARN }, + }) end) -map.n("]w", function() - vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR }) +nmap("[e", function() + vim.diagnostic.jump({ + count = -vim.v.count1, + severity = vim.diagnostic.severity.ERROR, + }) end) +nmap("]e", function() + vim.diagnostic.jump({ + count = vim.v.count1, + severity = vim.diagnostic.severity.ERROR, + }) +end) + +nmap( + "oq", + vim.diagnostic.setloclist, + "[O]pen diagnostic [Q]uickfix list" +) + +nmap("yp", function() + vim.fn.setreg("+", vim.fn.expand("%")) +end, "[Y]ank [P]ath") + +local sudo_exec = function(_cmd) + vim.fn.inputsave() + local password = vim.fn.inputsecret("Password: ") + vim.fn.inputrestore() + if not password or #password == 0 then + vim.notify("Invalid password, sudo aborted", vim.log.levels.WARN) + return false + end + local out = vim.fn.system(string.format("sudo -p '' -S %s", _cmd), password) + if vim.v.shell_error ~= 0 then + print("\r\n") + vim.notify(out, vim.log.levels.ERROR) + return false + end + return true +end + +vim.api.nvim_create_user_command("SudoWrite", function(opts) + local tmpfile = vim.fn.tempname() + local filepath + if #opts.fargs == 1 then + filepath = opts.fargs[1] + else + filepath = vim.fn.expand("%") + end + if not filepath or #filepath == 0 then + vim.notify("E32: No file name", vim.log.levels.ERROR) + return + end + -- `bs=1048576` is equivalent to `bs=1M` for GNU dd or `bs=1m` for BSD dd + -- Both `bs=1M` and `bs=1m` are non-POSIX + local _cmd = string.format( + "dd if=%s of=%s bs=1048576", + vim.fn.shellescape(tmpfile), + vim.fn.shellescape(filepath) + ) + -- no need to check error as this fails the entire function + vim.api.nvim_exec2(string.format("write! %s", tmpfile), { output = true }) + if sudo_exec(_cmd) then + -- refreshes the buffer and prints the "written" message + vim.cmd.checktime() + -- exit command mode + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes("", true, false, true), + "n", + true + ) + end + vim.fn.delete(tmpfile) +end, { + nargs = "?", + desc = "Write using sudo permissions", +}) diff --git a/home/.config/nvim/filetype.lua b/home/.config/nvim/filetype.lua index b13afe0..51f8646 100644 --- a/home/.config/nvim/filetype.lua +++ b/home/.config/nvim/filetype.lua @@ -3,5 +3,12 @@ vim.filetype.add({ eml = "mail", inc = "cpp", def = "cpp", + Jenkinsfile = "groovy", + }, + filename = { + [".devcontainer.json"] = "jsonc", + }, + pattern = { + [".*/.github/workflows/.*%.ya?ml"] = "yaml.ghaction", }, }) diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 05f7fa2..a683b33 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -8,19 +8,39 @@ function P(v) end local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release + "--branch=stable", + lazyrepo, lazypath, }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end end vim.opt.rtp:prepend(lazypath) + require("lazy").setup({ import = "custom/plugins" }, { defaults = { version = "*", }, + change_detection = { + notify = false, + }, + rocks = { + enabled = false, + hererocks = false, + }, }) + +vim.lsp.enable("just") diff --git a/home/.config/nvim/lsp/clangd.lua b/home/.config/nvim/lsp/clangd.lua new file mode 100644 index 0000000..e9868ae --- /dev/null +++ b/home/.config/nvim/lsp/clangd.lua @@ -0,0 +1,57 @@ +local function validate_bufnr(bufnr) + vim.validate("bufnr", bufnr, "number") + return bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr +end + +local function switch_source_header_splitcmd(bufnr, splitcmd) + local method_name = "textDocument/switchSourceHeader" + bufnr = validate_bufnr(bufnr) + local client = vim.lsp.get_clients({ bufnr = bufnr, name = "clangd" })[1] + if not client then + return vim.notify( + ("method %s is not supported by any servers active on the current buffer"):format( + method_name + ) + ) + end + local params = vim.lsp.util.make_text_document_params(bufnr) + client.request(method_name, params, function(err, result) + if err then + error(tostring(err)) + end + if not result then + vim.notify("corresponding file cannot be determined") + return + end + vim.api.nvim_cmd({ + cmd = splitcmd, + args = { vim.uri_to_fname(result) }, + }, {}) + end, bufnr) +end + +return { + capabilities = { + offsetEncoding = { "utf-16" }, + }, + on_attach = function(_, bufnr) + local function nmap(l, r, desc) + vim.keymap.set("n", l, r, { buffer = bufnr, desc = desc }) + end + nmap("gH", function() + switch_source_header_splitcmd(bufnr, "edit") + end, "[G]o to [H]eader") + nmap("gvH", function() + switch_source_header_splitcmd(bufnr, "vsplit") + end, "[G]o in a [V]ertical split to [H]eader") + nmap("gxH", function() + switch_source_header_splitcmd(bufnr, "split") + end, "[G]o in a [X]horizontal split to [H]eader") + nmap("gtH", function() + switch_source_header_splitcmd(bufnr, "tabedit") + end, "[G]o in a [T]ab to [H]eader") + end, + init_options = { + clangdFileStatus = true, + }, +} diff --git a/home/.config/nvim/lsp/lua_ls.lua b/home/.config/nvim/lsp/lua_ls.lua new file mode 100644 index 0000000..af0e681 --- /dev/null +++ b/home/.config/nvim/lsp/lua_ls.lua @@ -0,0 +1,9 @@ +return { + settings = { + Lua = { + diagnostics = { + disable = { "missing-fields" }, + }, + }, + }, +} diff --git a/home/.config/nvim/lua/cfg/options.lua b/home/.config/nvim/lua/cfg/options.lua index 05f563f..47489f1 100644 --- a/home/.config/nvim/lua/cfg/options.lua +++ b/home/.config/nvim/lua/cfg/options.lua @@ -1,4 +1,6 @@ -local opt = vim.opt +local opt = vim.o + +opt.termguicolors = true opt.undofile = true opt.swapfile = false @@ -8,6 +10,7 @@ opt.number = true opt.cursorline = true opt.signcolumn = "auto:2" opt.showmatch = true +opt.laststatus = 3 opt.expandtab = true opt.shiftround = true @@ -15,50 +18,62 @@ opt.shiftwidth = 0 opt.softtabstop = -1 opt.tabstop = 4 +opt.gdefault = true +opt.ignorecase = true +opt.smartcase = true + opt.splitbelow = true opt.splitright = true +opt.splitkeep = "screen" opt.linebreak = true opt.breakindent = true opt.textwidth = 80 opt.colorcolumn = "+1" -opt.formatoptions:remove("t") +vim.opt.formatoptions:remove("t") opt.cmdheight = 2 +-- vim.o.messagesopt = "wait:5000,history:500" -opt.shortmess:append({ a = true }) +vim.opt.shortmess:append({ a = true }) -opt.gdefault = true +opt.updatetime = 250 +opt.timeoutlen = 300 opt.synmaxcol = 500 -opt.completeopt = { "menu", "menuone", "noselect" } +vim.opt.completeopt = { "menuone", "noselect", "popup", "fuzzy" } opt.scrolloff = 999 opt.sidescrolloff = 5 -opt.clipboard = "unnamedplus" +vim.schedule(function() + opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" +end) + +vim.o.mouse = "a" -opt.wildmode = { "longest", "full" } +vim.opt.wildmode = { "longest", "full" } -opt.cpoptions:remove({ "_" }) +vim.opt.cpoptions:remove({ "_" }) -opt.listchars = { +vim.opt.listchars = { tab = "> ", - trail = "·", + space = "·", extends = ">", precedes = "<", nbsp = "+", } opt.list = true +opt.confirm = true + opt.virtualedit = "block" opt.spelloptions = "camel" -vim.g.is_posix = 1 -vim.g.python_host_prog = 0 -vim.g.python3_host_prog = 0 -vim.g.netrw_home = vim.fn.stdpath("data") +vim.g.loaded_node_provider = 0 +vim.g.loaded_perl_provider = 0 +vim.g.loaded_python3_provider = 0 -opt.diffopt:append({ +vim.opt.diffopt:append({ ["indent-heuristic"] = true, hiddenoff = true, iblank = true, @@ -68,22 +83,25 @@ opt.diffopt:append({ if vim.fn.executable("rg") then opt.grepprg = "rg\\ --vimgrep" - opt.grepformat:append("f:%l:%c:%m") + opt.grepformat = "f:%l:%c:%m" end -opt.termguicolors = true opt.pumblend = 20 -opt.foldmethod = "expr" -opt.foldexpr = "nvim_treesitter#foldexpr()" -opt.foldenable = false +vim.wo.foldmethod = "expr" +vim.wo.foldenable = false vim.g.mapleader = " " vim.g.maplocalleader = "," vim.diagnostic.config({ - virtual_text = { - source = "if_many", - severity = vim.diagnostic.severity.ERROR, - } + virtual_text = false, + virtual_lines = false, }) + +opt.sessionoptions = + "blank,buffers,curdir,help,tabpages,winsize,winpos,terminal,localoptions" + +vim.o.exrc = true + + diff --git a/home/.config/nvim/lua/cfg/utils.lua b/home/.config/nvim/lua/cfg/utils.lua index 7cd172a..300d7a7 100644 --- a/home/.config/nvim/lua/cfg/utils.lua +++ b/home/.config/nvim/lua/cfg/utils.lua @@ -12,9 +12,15 @@ function M.format_hunks(options) local start = hunk.added.start local last = start + hunk.added.count -- nvim_buf_get_lines uses zero-based indexing -> subtract from last - local last_hunk_line = vim.api.nvim_buf_get_lines(0, last - 2, last - 1, true)[1] - local range = { start = { start, 0 }, ["end"] = { last - 1, last_hunk_line:len() } } - options = vim.tbl_extend("force", { range = range, lsp_fallback = true, quiet = true }, options or {}) + local last_hunk_line = + vim.api.nvim_buf_get_lines(0, last - 2, last - 1, true)[1] + local range = + { start = { start, 0 }, ["end"] = { last - 1, last_hunk_line:len() } } + options = vim.tbl_extend( + "force", + { range = range, lsp_fallback = true, quiet = true }, + options or {} + ) conform.format(options) end end diff --git a/home/.config/nvim/lua/custom/plugins/completion.lua b/home/.config/nvim/lua/custom/plugins/completion.lua index 789a459..70fdba0 100644 --- a/home/.config/nvim/lua/custom/plugins/completion.lua +++ b/home/.config/nvim/lua/custom/plugins/completion.lua @@ -1,116 +1,96 @@ return { { - "hrsh7th/nvim-cmp", + "zbirenbaum/copilot.lua", + cmd = "Copilot", + build = ":Copilot auth", event = "InsertEnter", - config = function() - local cmp = require("cmp") - - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 - and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1] - :sub(col, col) - :match("%s") - == nil - end - - local luasnip = require("luasnip") - - cmp.setup({ - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - }, - formatting = { - format = function(entry, vim_item) - -- set a name for each source - vim_item.menu = ({ - path = "[Path]", - nvim_lsp = "[LSP]", - luasnip = "[LuaSnip]", - dap = "[dap]", - })[entry.source.name] - return vim_item - end, - }, - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - { name = "nvim_lsp_signature_help" }, - }, - }) - - require "cmp".setup.filetype( - { "dap-repl", "dapui_watches", "dapui_hover" }, { - sources = { - { name = "dap" }, - }, - }) - - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - end, + keys = { + { + "tc", + function() + require("copilot.command").toggle() + end, + desc = "[T]oggle [C]opilot attachment", + }, + }, + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + }, + }, + { + "saghen/blink.compat", + opts = {}, + }, + { + "saghen/blink.cmp", dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "hrsh7th/cmp-nvim-lsp-signature-help", + "rafamadriz/friendly-snippets", + "fang2hou/blink-copilot", "rcarriga/cmp-dap", - "windwp/nvim-autopairs", - { - "saadparwaiz1/cmp_luasnip", - dependencies = { - { - "L3MON4D3/LuaSnip", - event = "InsertCharPre", - keys = { - { "", function() require "luasnip".jump(1) end, mode = "i" }, - { "", function() require "luasnip".jump(-1) end, mode = "i" }, - }, - config = function() - require("luasnip/loaders/from_vscode").lazy_load() + }, + opts = { + keymap = { + preset = "cmdline", + [""] = { "accept", "fallback" }, + }, + appearance = { + use_nvim_cmp_as_default = true, + }, + completion = { + list = { + selection = { + preselect = function() + return not require("blink.cmp").snippet_active({ direction = 1 }) end, - dependencies = { - "kitagry/vs-snippets", - "rafamadriz/friendly-snippets", - "kkonghao/snippet-dog", + }, + }, + documentation = { auto_show = true }, + }, + signature = { + enabled = true, + trigger = { + enabled = true, + show_on_keyword = true, + show_on_insert = true, + }, + }, + sources = { + default = { "lazydev", "lsp", "copilot", "snippets", "path", "buffer" }, + per_filetype = { + ["dap-repl"] = { "dap" }, + }, + providers = { + path = { + opts = { + get_cwd = vim.fn.getcwd, }, - } + }, + copilot = { + name = "copilot", + module = "blink-copilot", + score_offset = 100, + async = true, + }, + lazydev = { + name = "LazyDev", + module = "lazydev.integrations.blink", + -- make lazydev completions top priority (see `:h blink.cmp`) + score_offset = 100, + }, + dap = { name = "dap", module = "blink.compat.source" }, }, }, }, }, + { + "saghen/blink.pairs", + version = "*", + dependencies = "saghen/blink.download", + opts = { + mappings = { + disabled_filetypes = { "TelescopePrompt" }, + }, + }, + }, } diff --git a/home/.config/nvim/lua/custom/plugins/debug.lua b/home/.config/nvim/lua/custom/plugins/debug.lua index 82de07d..cec04b1 100644 --- a/home/.config/nvim/lua/custom/plugins/debug.lua +++ b/home/.config/nvim/lua/custom/plugins/debug.lua @@ -1,237 +1,209 @@ -local map = require("mapper") - return { + { + "miroshQa/debugmaster.nvim", + branch = "dashboard", + dependencies = "mfussenegger/nvim-dap", + keys = { + { + "td", + function() + require("debugmaster").mode.toggle() + end, + desc = "[T]oggle [D]ebug mode", + }, + }, + }, { "mfussenegger/nvim-dap", config = function() local dap = require("dap") - dap.defaults.fallback.force_external_terminal = true - dap.defaults.fallback.external_terminal = { - command = "/usr/bin/st", - args = { "-e" }, - } - - dap.defaults.fallback.terminal_win_cmd = "50vsplit new" - local function get_env_vars() - local variables = {} - for k, v in pairs(vim.fn.environ()) do - table.insert(variables, string.format("%s=%s", k, v)) - end + local variables = vim.fn.environ() + table.insert(variables, { ASAN_OPTIONS = "detect_leaks=0" }) return variables end dap.adapters.lldb = { type = "executable", - command = "/usr/bin/lldb-vscode", + command = "lldb-dap", name = "lldb", + env = get_env_vars, + } + dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap" }, + env = get_env_vars, + } + dap.adapters.codelldb = { + type = "executable", + command = "codelldb", + env = get_env_vars, } - - local function str_split(inputstr, sep) - sep = sep or "%s" - local t = {} - for str in inputstr:gmatch("([^" .. sep .. "]+)") do - table.insert(t, str) - end - return t - end - - local _cmd = nil - - local function get_cmd() - if _cmd then - return _cmd - end - local clipboard_cmd = vim.fn.getreg("+") - _cmd = vim.fn.input({ - prompt = "Command to execute: ", - default = clipboard_cmd - }) - return _cmd - end local function get_program() - return str_split(get_cmd())[1] + local _program + vim.ui.input({ + prompt = "Program: ", + complete = "file_in_path", + }, function(res) + _program = res + end) + return vim.fn.system("which " .. _program):gsub("\n$", "") end local function get_args() - local argv = str_split(get_cmd()) - local args = {} - - if #argv < 2 then - return {} - end - - for i = 2, #argv do - args[#args + 1] = argv[i] - end - - return args + local _args + vim.ui.input({ + prompt = "Args: ", + default = vim.fn.getreg("+"), + complete = "file", + }, function(res) + _args = res + end) + return require("dap.utils").splitstr(_args) end dap.configurations.cpp = { + -- { + -- name = "GDB Launch", + -- type = "gdb", + -- request = "launch", + -- cwd = "${workspaceFolder}", + -- program = get_program, + -- args = get_args, + -- env = get_env_vars, + -- stopAtBeginningOfMainSubprogram = false, + -- }, + -- { + -- name = "LLDB Launch", + -- type = "lldb", + -- request = "launch", + -- cwd = "${workspaceFolder}", + -- program = get_program, + -- args = get_args, + -- env = get_env_vars, + -- stopOnEntry = true, + -- disableASLR = false, + -- }, { - name = "Launch", - type = "lldb", + name = "codelldb Launch", + type = "codelldb", request = "launch", cwd = "${workspaceFolder}", program = get_program, - stopOnEntry = true, args = get_args, - env = get_env_vars, - runInTerminal = true, - }, - { - -- If you get an "Operation not permitted" error using this, try disabling YAMA: - -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope - name = "Attach to process", - type = "lldb", - request = "attach", - pid = require('dap.utils').pick_process, + stopOnEntry = true, + console = "integratedTerminal", }, + -- { + -- name = "GDB Attach to process", + -- type = "gdb", + -- request = "attach", + -- pid = require('dap.utils').pick_process, + -- }, + -- { + -- name = "LLDB Attach to process", + -- type = "lldb", + -- request = "attach", + -- pid = require('dap.utils').pick_process, + -- }, + -- { + -- name = "codelldb Attach to process", + -- type = "codelldb", + -- request = "attach", + -- pid = require('dap.utils').pick_process, + -- }, } dap.configurations.c = dap.configurations.cpp dap.configurations.rust = dap.configurations.cpp - local get_python_path = function() - local venv_path = os.getenv("VIRTUAL_ENV") - if venv_path then - return venv_path .. "/bin/python" - end - return "/usr/bin/python" - end - - require("dap-python").setup(get_python_path()) - - dap.adapters.nlua = function(callback, config) - callback({ type = "server", host = config.host, port = config.port }) - end - - dap.configurations.lua = { - { - type = "nlua", - request = "attach", - name = "Attach to running Neovim instance", - host = function() - local value = vim.fn.input("Host [127.0.0.1]: ") - if value ~= "" then - return value - end - return "127.0.0.1" - end, - port = function() - local val = tonumber(vim.fn.input("Port: ")) - assert(val, "Please provide a port number") - return val - end, - }, - } - - dap.repl.commands = vim.tbl_extend("force", dap.repl.commands, { - continue = { "continue", "c" }, - next_ = { "next", "n" }, - back = { "back", "b" }, - reverse_continue = { "reverse-continue", "rc" }, - into = { "into" }, - into_target = { "into_target" }, - out = { "out" }, - scopes = { "scopes" }, - threads = { "threads" }, - frames = { "frames" }, - exit = { "exit", "quit", "q" }, - up = { "up" }, - down = { "down" }, - goto_ = { "goto" }, - capabilities = { "capabilities", "cap" }, - -- add your own commands - custom_commands = { - ["echo"] = function(text) - dap.repl.append(text) - end, - }, - }) - - map.n("", dap.close) - map.n("", dap.continue) - map.n("", dap.step_over) - map.n("", dap.step_into) - map.n("", dap.step_out) - map.n("b", dap.toggle_breakpoint) - map.n("B", function() - dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) - end) - map.n("lp", function() - dap.set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) - end) - map.n("dr", dap.repl.open) - map.n("dl", dap.run_last) - map.n("", dap.list_breakpoints) - - local dapui = require("dapui") - dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() - end - dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() - end - dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() - end - map.n("du", dapui.toggle) - map.v("de", dapui.eval) + -- local dapui = require("dapui") + -- dap.listeners.before.attach.dapui_config = dapui.open + -- dap.listeners.before.launch.dapui_config = dapui.open + -- dap.listeners.before.event_terminated.dapui_config = dapui.close + -- dap.listeners.before.event_exited.dapui_config = dapui.close + + -- local dv = require("dap-view") + -- dap.listeners.before.attach["dap-view-config"] = dv.open + -- dap.listeners.before.launch["dap-view-config"] = dv.open + -- dap.listeners.before.event_terminated["dap-view-config"] = dv.close + -- dap.listeners.before.event_exited["dap-view-config"] = dv.close end, dependencies = { + -- { + -- "igorlfs/nvim-dap-view", + -- keys = { + -- { + -- "td", + -- function() + -- require("dap-view").toggle(true) + -- end, + -- desc = "[T]oggle [D]ebug UI", + -- }, + -- }, + -- opts = {}, + -- }, + -- { + -- "rcarriga/nvim-dap-ui", + -- dependencies = "nvim-neotest/nvim-nio", + -- keys = { + -- { + -- "td", + -- function() + -- require("dapui").toggle() + -- end, + -- desc = "[T]oggle [D]ebug UI", + -- }, + -- { + -- "de", + -- function() + -- require("dapui").eval() + -- end, + -- desc = "[D]ebug [E]valuate", + -- }, + -- }, + -- opts = { + -- icons = { expanded = "-", collapsed = "+", current_frame = "*" }, + -- controls = { enabled = false }, + -- layouts = { + -- { + -- elements = { + -- -- Elements can be strings or table with id and size keys. + -- "scopes", + -- "breakpoints", + -- "stacks", + -- "watches", + -- }, + -- size = 40, + -- position = "left", + -- }, + -- { + -- elements = { + -- "repl", + -- }, + -- size = 0.25, -- 25% of total lines + -- position = "bottom", + -- }, + -- }, + -- }, + -- }, { - "rcarriga/nvim-dap-ui", - dependencies = "nvim-neotest/nvim-nio", - opts = { - icons = { expanded = "-", collapsed = "+", current_frame = "*" }, - controls = { enabled = false }, - layouts = { - { - elements = { - -- Elements can be strings or table with id and size keys. - "scopes", - "breakpoints", - "stacks", - "watches", - }, - size = 40, - position = "left", - }, - { - elements = { - "repl", - }, - size = 0.25, -- 25% of total lines - position = "bottom", - }, - }, - }, + "theHamsta/nvim-dap-virtual-text", + opts = {}, + dependencies = { "nvim-treesitter/nvim-treesitter" }, }, + "williamboman/mason.nvim", { - "mfussenegger/nvim-dap-python", - keys = { - { "gm", function() - require("dap-python").test_method() - end }, - { - "g", - function() - require("dap-python").debug_selection() - end, - mode = "v" - }, + "jay-babu/mason-nvim-dap.nvim", + opts = { + automatic_installation = false, + handlers = {}, + ensure_installed = {}, }, }, - "jbyuki/one-small-step-for-vimkind", - { - "theHamsta/nvim-dap-virtual-text", - config = true, - dependencies = { "nvim-treesitter/nvim-treesitter" } - } }, }, } diff --git a/home/.config/nvim/lua/custom/plugins/ft.lua b/home/.config/nvim/lua/custom/plugins/ft.lua deleted file mode 100644 index 769db86..0000000 --- a/home/.config/nvim/lua/custom/plugins/ft.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "kovetskiy/sxhkd-vim", - "tmux-plugins/vim-tmux", - "martinda/Jenkinsfile-vim-syntax", - "rhysd/vim-llvm", - "wgwoods/vim-systemd-syntax", -} diff --git a/home/.config/nvim/lua/custom/plugins/git.lua b/home/.config/nvim/lua/custom/plugins/git.lua index 077cfd4..3e41626 100644 --- a/home/.config/nvim/lua/custom/plugins/git.lua +++ b/home/.config/nvim/lua/custom/plugins/git.lua @@ -1,8 +1,7 @@ -local map = require("mapper") - return { { - 'akinsho/git-conflict.nvim', + "akinsho/git-conflict.nvim", + event = "BufRead", opts = { disable_diagnostics = true, highlights = { @@ -11,10 +10,10 @@ return { ancestor = nil, }, default_mappings = { - next = ']x', - prev = '[x', + next = "]x", + prev = "[x", }, - } + }, }, { "NeogitOrg/neogit", @@ -22,46 +21,55 @@ return { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim", }, - config = function() - local neogit = require("neogit") - neogit.setup({ - disable_commit_confirmation = true, - kind = "split", - console_timeout = 5000, - auto_show_console = false, - }) - map.n("ng", neogit.open) - end, + keys = { + { + "go", + function() + require("neogit").open() + end, + desc = "neo[G]it [O]pen", + }, + }, + cmd = "Neogit", + opts = { + disable_commit_confirmation = true, + kind = "split", + console_timeout = 5000, + auto_show_console = false, + }, }, { "ruifm/gitlinker.nvim", keys = { - { "gy", function() require 'gitlinker'.get_buf_range_url("n") end }, { "gy", function() - require 'gitlinker'.get_buf_range_url("v") + require("gitlinker").get_buf_range_url("n") end, - mode = "v" + }, + { + "gy", + function() + require("gitlinker").get_buf_range_url("v") + end, + mode = "v", }, }, dependencies = { "nvim-lua/plenary.nvim", }, - config = function() - require "gitlinker".setup({ - callbacks = { - ["git.sommerfeld.dev"] = function(url_data) - local url = require "gitlinker.hosts".get_base_https_url(url_data) - url = url .. "/tree/" .. url_data.file .. "?id=" .. url_data.rev - if url_data.lstart then - url = url .. "#n" .. url_data.lstart - end - return url + opts = { + callbacks = { + ["git.sommerfeld.dev"] = function(url_data) + local url = require("gitlinker.hosts").get_base_https_url(url_data) + url = url .. "/tree/" .. url_data.file .. "?id=" .. url_data.rev + if url_data.lstart then + url = url .. "#n" .. url_data.lstart end - }, - }) - end, + return url + end, + }, + }, }, { "lewis6991/gitsigns.nvim", @@ -77,48 +85,80 @@ return { _threaded_diff = true, _refresh_staged_on_update = true, on_attach = function(bufnr) - local gs = require('gitsigns') - + local gs = require("gitsigns") + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc }) + end + local function nmap(l, r, desc) + map("n", l, r, desc) + end + local function vmap(l, r, desc) + map("v", l, r, desc) + end -- Navigation - map.n(']c', function() + nmap("]c", function() if vim.wo.diff then - vim.cmd.normal({ ']c', bang = true }) + vim.cmd.normal({ "]c", bang = true }) else - gs.nav_hunk('next') + gs.nav_hunk("next") end - end, nil, bufnr) + end, "Jump to next git [c]hange") - map.n('[c', function() + nmap("[c", function() if vim.wo.diff then - vim.cmd.normal({ '[c', bang = true }) + vim.cmd.normal({ "[c", bang = true }) else - gs.nav_hunk('prev') + gs.nav_hunk("prev") end - end, nil, bufnr) + end, "Jump to previous git [c]hange") -- Actions - map.n('hs', gs.stage_hunk, nil, bufnr) - map.n('hr', gs.reset_hunk, nil, bufnr) - map.v('hs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end, nil, bufnr) - map.v('hr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end, nil, bufnr) - map.n('hS', gs.stage_buffer, nil, bufnr) - map.n('hu', gs.undo_stage_hunk, nil, bufnr) - map.n('hR', gs.reset_buffer, nil, bufnr) - map.n('hp', gs.preview_hunk, nil, bufnr) - map.n('hb', function() gs.blame_line { full = true } end, nil, - bufnr) - map.n('tb', gs.toggle_current_line_blame, nil, bufnr) - map.n('hd', gs.diffthis, nil, bufnr) - map.n('hD', function() gs.diffthis('~') end, nil, bufnr) - map.n('hc', gs.change_base, nil, bufnr) - map.n('hC', function() gs.change_base('~') end, nil, bufnr) - map.n('td', gs.toggle_deleted, nil, bufnr) - map.n('tw', gs.toggle_word_diff, nil, bufnr) - map.n('tl', gs.toggle_linehl, nil, bufnr) - + nmap("hs", gs.stage_hunk, "git [s]tage hunk") + nmap("hr", gs.reset_hunk, "git [r]eset hunk") + vmap("hs", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "git [s]tage hunk") + vmap("hr", function() + gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "git [r]eset hunk") + nmap("hS", gs.stage_buffer, "git [S]tage buffer") + nmap("hR", gs.reset_buffer, "git [R]eset buffer") + nmap("hp", gs.preview_hunk, "git [p]review hunk") + nmap("hb", function() + gs.blame_line({ full = true }) + end, "git [b]lame line") + nmap( + "tb", + gs.toggle_current_line_blame, + "[T]oggle git show [b]lame line" + ) + nmap("hd", gs.diffthis, "git [d]iff against index") + nmap("hD", function() + gs.diffthis("~") + end, "git [D]iff against last commit") + nmap("hc", gs.change_base, "git [C]hange base to index") + nmap("hC", function() + gs.change_base("~") + end, "git [C]hange base to HEAD") + nmap( + "tgd", + gs.preview_hunk_inline, + "[T]oggle [G]it show [D]eleted" + ) + nmap("tgw", gs.toggle_word_diff, "[T]oggle [G]it [W]ord diff") + nmap( + "tgl", + gs.toggle_linehl, + "[T]oggle [G]it [L]ine highlighting" + ) -- Text object - map.map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', nil, bufnr) - end + map( + { "o", "x" }, + "ih", + ":Gitsigns select_hunk", + "git [H]unk text object" + ) + end, }, dependencies = { "nvim-lua/plenary.nvim", diff --git a/home/.config/nvim/lua/custom/plugins/init.lua b/home/.config/nvim/lua/custom/plugins/init.lua index ed597ba..3b7c821 100644 --- a/home/.config/nvim/lua/custom/plugins/init.lua +++ b/home/.config/nvim/lua/custom/plugins/init.lua @@ -1,38 +1,463 @@ -local map = require("mapper") - return { - { "nvim-lua/plenary.nvim", lazy = true }, - { "tpope/vim-repeat", event = "VeryLazy" }, - 'tpope/vim-sleuth', + { "nvim-lua/plenary.nvim", branch = "master", lazy = true }, { - 'tummetott/unimpaired.nvim', - keys = { "]", "[", "yo" }, - opts = { - -- add options here if you wish to override the default settings - }, + "nmac427/guess-indent.nvim", + event = "BufRead", + opts = {}, }, - { "kylechui/nvim-surround", config = true }, { - "Julian/vim-textobj-variable-segment", - dependencies = { "kana/vim-textobj-user" }, + "kylechui/nvim-surround", + event = "VeryLazy", + opts = {}, + }, + { + "chrisgrieser/nvim-various-textobjs", + event = "VeryLazy", + opts = { + keymaps = { + useDefaults = true, + }, + }, }, { "monaqa/dial.nvim", - config = function() - map.n("]i", require("dial.map").inc_normal()) - map.n("[i", require("dial.map").dec_normal()) - map.v("]i", require("dial.map").inc_visual()) - map.v("[i", require("dial.map").dec_visual()) - end + keys = { + { + "]i", + function() + require("dial.map").inc_normal() + end, + expr = true, + desc = "Increment", + }, + { + "[i", + function() + require("dial.map").dec_normal() + end, + expr = true, + desc = "Decrement", + }, + { + "]i", + function() + require("dial.map").inc_visual() + end, + expr = true, + mode = "v", + desc = "Increment", + }, + { + "[i", + function() + require("dial.map").dec_visual() + end, + expr = true, + mode = "v", + desc = "Decrement", + }, + }, + config = function() end, }, { "iamcco/markdown-preview.nvim", cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, build = "cd app && yarn install", - ft = { "markdown" }, + ft = "markdown", }, { "kwkarlwang/bufresize.nvim", - config = true + event = "VeryLazy", + opts = {}, + }, + { + "rmagatti/auto-session", + lazy = false, + opts = function() + -- Convert the cwd to a simple file name + local function get_cwd_as_name() + local dir = vim.fn.getcwd(0) + return dir:gsub("[^A-Za-z0-9]", "_") + end + local overseer = require("overseer") + return { + use_git_branch = true, + pre_save_cmds = { + function() + overseer.save_task_bundle( + get_cwd_as_name(), + -- Passing nil will use config.opts.save_task_opts. You can call list_tasks() explicitly and + -- pass in the results if you want to save specific tasks. + nil, + { on_conflict = "overwrite" } -- Overwrite existing bundle, if any + ) + end, + }, + -- Optionally get rid of all previous tasks when restoring a session + pre_restore_cmds = { + function() + for _, task in ipairs(overseer.list_tasks({})) do + task:dispose(true) + end + end, + }, + post_restore_cmds = { + function() + overseer.load_task_bundle( + get_cwd_as_name(), + { ignore_missing = true, autostart = false } + ) + end, + }, + save_extra_data = function(_) + local ok, breakpoints = pcall(require, "dap.breakpoints") + if not ok or not breakpoints then + return + end + + local bps = {} + local breakpoints_by_buf = breakpoints.get() + for buf, buf_bps in pairs(breakpoints_by_buf) do + bps[vim.api.nvim_buf_get_name(buf)] = buf_bps + end + if vim.tbl_isempty(bps) then + return + end + local extra_data = { + breakpoints = bps, + } + return vim.fn.json_encode(extra_data) + end, + + restore_extra_data = function(_, extra_data) + local json = vim.fn.json_decode(extra_data) + + if json.breakpoints then + local ok, breakpoints = pcall(require, "dap.breakpoints") + + if not ok or not breakpoints then + return + end + vim.notify("restoring breakpoints") + for buf_name, buf_bps in pairs(json.breakpoints) do + for _, bp in pairs(buf_bps) do + local line = bp.line + local opts = { + condition = bp.condition, + log_message = bp.logMessage, + hit_condition = bp.hitCondition, + } + breakpoints.set(opts, vim.fn.bufnr(buf_name), line) + end + end + end + end, + suppressed_dirs = { "~/", "/" }, + } + end, + }, + { + "aserowy/tmux.nvim", + event = "VeryLazy", + opts = { + resize = { + enable_default_keybindings = false, + }, + }, + }, + { + "stevearc/overseer.nvim", + keys = { + { + "to", + function() + require("overseer").toggle() + end, + desc = "[T]oggle [O]verseer", + }, + { + "ob", + function() + require("overseer").run_template({ + name = "just build", + prompt = "never", + }) + end, + desc = "[O]verseer [B]uild", + }, + { + "ot", + function() + require("overseer").run_template({ + name = "just test", + prompt = "never", + }) + end, + desc = "[O]verseer [J]ust [T]est", + }, + { + "of", + function() + require("overseer").run_template({ + name = "just test", + prompt = "never", + params = { target = vim.fn.expand("%") }, + }) + end, + desc = "[O]verseer test [F]ile", + }, + { + "oa", + function() + require("overseer").run_template({ + name = "just test_autofix", + prompt = "never", + params = { target = vim.fn.expand("%") }, + }) + end, + desc = "[O]verseer [A]utofix", + }, + { + "or", + function() + require("overseer").run_template() + end, + desc = "[O]verseer [R]un", + }, + { + "os", + function() + require("overseer").run_template({ name = "shell" }) + end, + desc = "[O]verseer [S]hell", + }, + { + "ol", + function() + local tasks = require("overseer").list_tasks({ recent_first = true }) + if vim.tbl_isempty(tasks) then + vim.notify("No tasks found", vim.log.levels.WARN) + else + require("overseer").run_action(tasks[1], "restart") + end + end, + desc = "[O]verseer run [L]ast", + }, + }, + config = function() + local overseer = require("overseer") + overseer.setup({}) + overseer.add_template_hook({ name = ".*" }, function(task_defn, util) + util.add_component( + task_defn, + { "open_output", on_start = "never", on_complete = "failure" } + ) + end) + end, + }, + { + "ThePrimeagen/refactoring.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + keys = { + { + "re", + function() + require("refactoring").refactor("Extract Function") + end, + mode = "x", + desc = "[R]efactor [E]xtract function", + }, + { + "rf", + function() + require("refactoring").refactor("Extract Function To File") + end, + mode = "x", + desc = "[R]efactor extract function to [F]ile", + }, + { + "rv", + function() + require("refactoring").refactor("Extract Variable") + end, + mode = "x", + desc = "[R]efactor extract [V]ariable", + }, + { + "rI", + function() + require("refactoring").refactor("Inline Function") + end, + desc = "[R]efactor [I]nline function", + }, + { + "ri", + function() + require("refactoring").refactor("Inline Variable") + end, + mode = { "x", "n" }, + desc = "[R]efactor [I]nline variable", + }, + { + "rb", + function() + require("refactoring").refactor("Extract Block") + end, + desc = "[R]efactor extract [B]lock", + }, + { + "rB", + function() + require("refactoring").refactor("Extract Block To File") + end, + desc = "[R]efactor extract [B]lock to file", + }, + { + "rp", + function() + require("refactoring").debug.printf({}) + end, + desc = "[R]efactor [P]rint", + }, + + { + "rv", + function() + require("refactoring").debug.print_var({}) + end, + mode = { "x", "n" }, + desc = "[R]efactor [P]rint [V]ariable", + }, + { + "rc", + function() + require("refactoring").debug.cleanup({}) + end, + desc = "[R]efactor [C]leanup", + }, + }, + opts = {}, + config = function() + local refactoring = require("refactoring") + refactoring.setup({}) + end, + }, + { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + spec = { + { "g", group = "[G]oto" }, + { "yo", group = "Toggle options" }, + { "]", group = "Navigate to next" }, + { "[", group = "Navigate to previous" }, + { "c", group = "[C]ode", mode = { "n", "x" } }, + { "d", group = "[D]ocument" }, + { "g", group = "[G]it" }, + { "h", group = "Git [H]unk", mode = { "n", "v" } }, + { "n", group = "[N]eotest" }, + { "o", group = "[O]verseer" }, + { "r", group = "[R]efactor" }, + { "s", group = "[S]earch" }, + { "w", group = "[W]orkspace" }, + { "t", group = "[T]oggle" }, + }, + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, + }, + { + "stevearc/quicker.nvim", + event = "FileType qf", + keys = { + { + "tq", + function() + require("quicker").toggle() + end, + desc = "[T]oggle [Q]uickfix", + }, + { + "tl", + function() + require("quicker").toggle({ loclist = true }) + end, + desc = "[T]oggle [L]oclist", + }, + }, + opts = { + keys = { + { + ">", + function() + require("quicker").expand({ + before = 2, + after = 2, + add_to_existing = true, + }) + end, + desc = "Expand quickfix context", + }, + { + "<", + function() + require("quicker").collapse() + end, + desc = "Collapse quickfix context", + }, + }, + }, + }, + { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + keys = { + { + "aa", + "CodeCompanionActions", + { "n", "v" }, + { noremap = true, silent = true, desc = "[A]I [A]ctions" }, + }, + { + "ta", + "CodeCompanionChat Toggle", + { "n", "v" }, + { noremap = true, silent = true, desc = "[T]oggle [A]I chat" }, + }, + { + "ac", + "CodeCompanionChat Add", + "v", + { noremap = true, silent = true, desc = "[A]I [C]chat add" }, + }, + }, + opts = { + strategies = { + chat = { + adapter = "copilot", + }, + inline = { + adapter = "copilot", + }, + }, + }, + }, + { + "stevearc/oil.nvim", + opts = {}, + lazy = false, }, } diff --git a/home/.config/nvim/lua/custom/plugins/lsp.lua b/home/.config/nvim/lua/custom/plugins/lsp.lua index b351e10..8ddbbac 100644 --- a/home/.config/nvim/lua/custom/plugins/lsp.lua +++ b/home/.config/nvim/lua/custom/plugins/lsp.lua @@ -1,198 +1,117 @@ -local map = require("mapper") - -local function handler_splitcmd(_, uri, splitcmd) - if not uri or uri == "" then - vim.api.nvim_echo({ { "Corresponding file cannot be determined" } }, false, {}) - return - end - local file_name = vim.uri_to_fname(uri) - vim.api.nvim_cmd({ - cmd = splitcmd, - args = { file_name }, - }, {}) -end - -local function switch_source_header_splitcmd(bufnr, splitcmd) - bufnr = bufnr or 0 - vim.lsp.buf_request(bufnr, "textDocument/switchSourceHeader", { - uri = vim.uri_from_bufnr(bufnr), - }, function(err, uri) return handler_splitcmd(err, uri, splitcmd) end) -end - -local function edit_source_header(bufnr) - switch_source_header_splitcmd(bufnr, "edit") -end - -local function split_source_header(bufnr) - switch_source_header_splitcmd(bufnr, "split") -end - -local function vsplit_source_header(bufnr) - switch_source_header_splitcmd(bufnr, "vsplit") -end - -local function tabedit_source_header(bufnr) - switch_source_header_splitcmd(bufnr, "tabedit") -end - return { + { + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + }, + }, { "lewis6991/hover.nvim", - config = function() - require("hover").setup { - init = function() - require("hover.providers.lsp") - require('hover.providers.gh') - require('hover.providers.man') - -- require('hover.providers.dictionary') + keys = { + { + "K", + function() + require("hover").hover({}) end, - } - - vim.keymap.set("n", "K", require("hover").hover, { desc = "hover.nvim" }) - vim.keymap.set("n", "gh", require("hover").hover, { desc = "hover.nvim" }) - vim.keymap.set("n", "gK", require("hover").hover_select, - { desc = "hover.nvim (select)" }) - end + desc = "Hover", + }, + { + "gK", + function() + require("hover").hover_select({}) + end, + desc = "Hover Select", + }, + { + "gh", + function() + require("hover").hover({}) + end, + desc = "[H]over", + }, + }, + opts = { + init = function() + require("hover.providers.lsp") + require("hover.providers.man") + require("hover.providers.dap") + -- require("hover.providers.gh") + require("hover.providers.dictionary") + end, + }, }, { - 'neovim/nvim-lspconfig', - config = function() - local lspconfig = require("lspconfig") - -- Enable (broadcasting) snippet capability for completion - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true - if pcall(require, "cmp_nvim_lsp") then - capabilities = require("cmp_nvim_lsp").default_capabilities() - end - - lspconfig.util.default_config = vim.tbl_extend( - "force", - lspconfig.util.default_config, - { - capabilities = capabilities, - } - ) - - local servers = { - bashls = {}, - dockerls = {}, - fortls = {}, - lua_ls = {}, - ruff = {}, - ts_ls = {}, - pyright = {}, - clangd = { - on_attach = function(_, bufnr) - map.n("gH", edit_source_header, { buffer = bufnr }) - map.n("gvH", vsplit_source_header, { buffer = bufnr }) - map.n("gxH", split_source_header, { buffer = bufnr }) - map.n("gtH", tabedit_source_header, { buffer = bufnr }) - end, - init_options = { - clangdFileStatus = true, + "neovim/nvim-lspconfig", + version = false, + dependencies = { + { "j-hui/fidget.nvim", opts = {} }, + "saghen/blink.cmp", + { "williamboman/mason.nvim", opts = {} }, + { + "williamboman/mason-lspconfig.nvim", + opts = { + ensure_installed = {}, + automatic_installation = false, + handlers = { + function(server_name) + vim.lsp.enable(server_name) + end, }, }, - } - - for server, config in pairs(servers) do - local cmd = config.cmd - local config_def = lspconfig[server].config_def - if not cmd and config_def then - local default_config = config_def.default_config - if default_config then - cmd = default_config.cmd - end - end - if cmd then - if vim.fn.executable(cmd[1]) == 1 then - lspconfig[server].setup(config) - end - end - end - - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local bufnr = args.buf - local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) - - if client.supports_method("textDocument/codeLens") then - vim.api.nvim_create_autocmd( - { "CursorHold", "CursorHoldI", "InsertLeave" }, - { buffer = bufnr, callback = vim.lsp.codelens.refresh } - ) - map.n("gl", vim.lsp.codelens.run, { buffer = bufnr }) - end - - map.n("", vim.lsp.buf.definition, { buffer = bufnr }) - map.n("gD", vim.lsp.buf.declaration, { buffer = bufnr }) - map.n("gR", vim.lsp.buf.rename, { buffer = bufnr }) - map.n("ga", vim.lsp.buf.code_action, { buffer = bufnr }) - map.v("ga", vim.lsp.buf.code_action, { buffer = bufnr }) - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - if client.server_capabilities.documentHighlightProvider then - local highlight_augroup = vim.api.nvim_create_augroup('lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = bufnr, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = bufnr, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'lsp-highlight', buffer = event2.buf } - end, - }) - end - - -- The following autocommand is used to enable inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then - map.n('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({})) - vim.lsp.inlay_hint.enable() - end, { buffer = bufnr }) - end - end, - }) - end, - dependencies = { - { 'folke/neodev.nvim', opts = {} }, + }, + { + "WhoIsSethDaniel/mason-tool-installer.nvim", + opts = { + ensure_installed = { + -- "nginx-language-server", -- needs python <= 3.12 + -- "just-lsp", -- "Platform unsupported" + "actionlint", + "autotools-language-server", + "bash-language-server", + "clangd", + "codelldb", + "codespell", + "css-lsp", + "dockerfile-language-server", + "fortls", + "gh", + "gh-actions-language-server", + "groovy-language-server", + "hadolint", + "html-lsp", + "jq", + "jsonlint", + "lua-language-server", + "markdownlint", + "mdformat", + "neocmakelsp", + "nginx-config-formatter", + "npm-groovy-lint", + "prettier", + "ruff", + "rust-analyzer", + "shellcheck", + -- "shellharden", + "shfmt", + "stylelint", + "stylua", + "systemd-language-server", + "systemdlint", + "typescript-language-server", + "typos", + "yamllint", + "yq", + }, + }, + }, }, - }, - { - "ray-x/lsp_signature.nvim", - event = "VeryLazy", config = function() - local lsp_signature = require "lsp_signature" - lsp_signature.setup({}) - - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local bufnr = args.buf - local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) - if client.supports_method("textDocument/signatureHelp") then - require("lsp_signature").on_attach({}, bufnr) - map.n("gs", vim.lsp.buf.signature_help, { buffer = bufnr }) - end - end, - }) - end + vim.lsp.enable("just") + vim.lsp.enable("tblgen_lsp_server") + end, }, { "stevearc/conform.nvim", @@ -205,19 +124,32 @@ return { require("conform").format({ async = true, lsp_fallback = true }) end, mode = "", - desc = "Format buffer", + desc = "[F]ormat buffer", }, }, config = function() require("conform").setup({ formatters_by_ft = { - python = { "ruff_format" }, + awk = { "gawk" }, + bash = { "shfmt" }, cmake = { "cmake_format" }, - json = { "jq" }, + css = { "prettier", "stylelint" }, + groovy = { "npm-groovy-lint" }, + html = { "prettier" }, + javascript = { "prettier" }, + typecript = { "prettier" }, + jenkins = { "npm-groovy-lint" }, + json = { "jq", "jsonlint" }, + jsonc = { "prettier" }, + just = { "just" }, + markdown = { "mdformat" }, + nginx = { "nginxfmt" }, + lua = { "stylua" }, + python = { "ruff_format", "ruff_fix", "ruff_organize_imports" }, rust = { "rustfmt" }, - sh = { "shfmt" }, - bash = { "shfmt" }, - zsh = { "shfmt" }, + sh = { "shfmt", "shellcheck", "shellharden" }, + yaml = { "yamllint" }, + zsh = { "shfmt", "shellcheck", "shellharden" }, }, default_format_opts = { lsp_format = "fallback", @@ -229,29 +161,80 @@ return { }, }) vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" - vim.api.nvim_create_autocmd("BufWritePre", { - callback = require "cfg.utils".format_hunks, - }) end, }, { - 'mrcjkb/rustaceanvim', - lazy = false, + "mrcjkb/rustaceanvim", + ft = "rust", }, { "mfussenegger/nvim-lint", - event = { 'BufReadPre', 'BufNewFile' }, + event = { "BufReadPre", "BufNewFile" }, config = function() - local lint = require('lint') + local lint = require("lint") + lint.linters_by_ft = { + css = { "stylelint" }, dockerfile = { "hadolint" }, + groovy = { "npm-groovy-lint" }, + jenkins = { "npm-groovy-lint" }, + json = { "jsonlint" }, + markdown = { "markdownlint" }, + makefile = { "checkmake" }, + systemd = { "systemdlint" }, + yaml = { "yamllint", "yq" }, + ghaction = { "actionlint" }, + zsh = { "zsh" }, + ["*"] = { "codespell", "typos" }, } - vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost", "InsertLeave" }, { + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost" }, { + group = lint_augroup, callback = function() - lint.try_lint() - end + if vim.opt_local.modifiable:get() then + lint.try_lint() + end + end, }) - end + end, }, { "j-hui/fidget.nvim", opts = {} }, + { + "rachartier/tiny-inline-diagnostic.nvim", + event = "VeryLazy", + priority = 1000, + opts = { + options = { + show_source = { + if_many = true, + }, + -- Set the arrow icon to the same color as the first diagnostic severity + set_arrow_to_diag_color = true, + -- Configuration for multiline diagnostics + -- Can be a boolean or a table with detailed options + multilines = { + -- Enable multiline diagnostic messages + enabled = true, + }, + + -- Display all diagnostic messages on the cursor line, not just those under cursor + show_all_diags_on_cursorline = true, + -- Enable diagnostics in Select mode (e.g., when auto-completing with Blink) + enable_on_select = true, + -- Configuration for breaking long messages into separate lines + break_line = { + -- Enable breaking messages after a specific length + enabled = true, + }, + -- Filter diagnostics by severity levels + -- Available severities: vim.diagnostic.severity.ERROR, WARN, INFO, HINT + severity = { + vim.diagnostic.severity.ERROR, + vim.diagnostic.severity.WARN, + vim.diagnostic.severity.INFO, + vim.diagnostic.severity.HINT, + }, + }, + }, + }, } diff --git a/home/.config/nvim/lua/custom/plugins/telescope.lua b/home/.config/nvim/lua/custom/plugins/telescope.lua index d2e97d7..ed88754 100644 --- a/home/.config/nvim/lua/custom/plugins/telescope.lua +++ b/home/.config/nvim/lua/custom/plugins/telescope.lua @@ -1,129 +1,341 @@ -local map = require("mapper") - return { { "nvim-telescope/telescope.nvim", + branch = "master", + keys = { + { + "sg", + function() + require("telescope.builtin").live_grep() + end, + desc = "[S]earch by [G]rep", + }, + { + "sw", + function() + require("telescope.builtin").grep_string() + end, + desc = "[S]earch current [W]ord", + }, + { + "sf", + function() + require("telescope.builtin").find_files() + end, + desc = "[S]earch [F]iles", + }, + { + "", + function() + require("telescope.builtin").buffers() + end, + desc = "[ ] Find existing buffers", + }, + { + "/", + function() + require("telescope.builtin").current_buffer_fuzzy_find() + end, + desc = "[/] Fuzzily search in current buffer", + }, + { + "s/", + function() + require("telescope.builtin").live_grep({ + grep_open_files = true, + prompt_title = "Live Grep in Open Files", + }) + end, + desc = "[S]earch [/] in Open Files", + }, + { + "st", + function() + require("telescope.builtin").treesitter() + end, + desc = "[S]earch [T]reesitter", + }, + { + "ss", + function() + require("telescope.builtin").builtin() + end, + desc = "[S]earch [S]elect Telescope", + }, + { + "sc", + function() + require("telescope.builtin").commands() + end, + desc = "[S]earch [C]ommands", + }, + { + "sh", + function() + require("telescope.builtin").help_tags() + end, + desc = "[S]earch [H]elp", + }, + { + "sm", + function() + require("telescope.builtin").man_pages() + end, + desc = "[S]earch [M]an pages", + }, + { + "sk", + function() + require("telescope.builtin").keymaps() + end, + desc = "[S]earch [K]eymaps", + }, + { + "sd", + function() + require("telescope.builtin").diagnostics() + end, + desc = "[S]earch [D]iagnostics", + }, + -- {"sr", function() require("telescope.builtin").resume() end, desc = '[S]earch [R]esume' }, + { + "s.", + function() + require("telescope.builtin").oldfiles() + end, + desc = '[S]earch Recent Files ("." for repeat)', + }, + { + "sq", + function() + require("telescope.builtin").quickfix() + end, + desc = "[S]earch [Q]uickfixlist", + }, + { + "sl", + function() + require("telescope.builtin").loclist() + end, + desc = "[S]earch [L]ocationlist", + }, + { + "sR", + function() + require("telescope.builtin").registers() + end, + desc = "[S]earch [R]egisters", + }, + { + "sa", + function() + require("telescope.builtin").autocommands() + end, + desc = "[S]earch [A]utocommands", + }, + + { + "gc", + function() + require("telescope.builtin").git_bcommits() + end, + desc = "[G]it buffer [C]commits", + }, + { + "gc", + function() + require("telescope.builtin").git_bcommits_range() + end, + desc = "[G]it [C]commits for selected range", + }, + { + "gC", + function() + require("telescope.builtin").git_commits() + end, + desc = "[G]it (all) [C]commits", + }, + { + "gb", + function() + require("telescope.builtin").git_branches() + end, + desc = "[G]it [B]ranches", + }, + { + "gs", + function() + require("telescope.builtin").git_status() + end, + desc = "[G]it [S]tatus", + }, + { + "gS", + function() + require("telescope.builtin").git_stash() + end, + desc = "[G]it [S]tash", + }, + { + "sr", + function() + require("telescope").extensions.refactoring.refactors() + end, + mode = { "n", "x" }, + desc = "[S]earch [R]efactor", + }, + }, config = function() local actions = require("telescope.actions") + local actions_layout = require("telescope.actions.layout") require("telescope").setup({ defaults = { sorting_strategy = "ascending", layout_config = { prompt_position = "top", + height = 0.95, + width = 0.95, + flip_columns = 200, + vertical = { mirror = true }, + }, + layout_strategy = "flex", + preview = { + filesize_limit = 0.1, -- MB }, scroll_strategy = "cycle", selection_strategy = "follow", color_devicons = false, mappings = { + n = { + [""] = actions_layout.toggle_preview, + ["d"] = actions.delete_buffer + actions.move_to_top, + ["a"] = actions.add_to_qflist, + ["s"] = actions.select_all, + }, i = { + ["jj"] = { "", type = "command" }, [""] = actions.move_selection_next, [""] = actions.move_selection_previous, + [""] = false, + [""] = actions_layout.toggle_preview, + [""] = actions.delete_buffer + actions.move_to_top, }, }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" + }, + pickers = { + find_files = { + follow = true, + hidden = true, + find_command = { + "fd", + "--type", + "f", + "--color", + "never", }, - ["ui-select"] = { - require("telescope.themes").get_dropdown({ - -- even more opts - }), + }, + live_grep = { + additional_args = { + "--hidden", + "--fixed-strings", }, }, + buffers = { + initial_mode = "normal", + sort_lastused = true, + }, + current_buffer_fuzzy_find = { + require("telescope.themes").get_dropdown({ + winblend = 10, + previewer = false, + }), + }, + quickfix = { + initial_mode = "normal", + }, + loclist = { + initial_mode = "normal", + }, + registers = { + initial_mode = "normal", + }, + lsp_definitions = { + initial_mode = "normal", + }, + lsp_type_definitions = { + initial_mode = "normal", + }, + lsp_implementations = { + initial_mode = "normal", + }, + lsp_references = { + initial_mode = "normal", + }, + lsp_incoming_calls = { + initial_mode = "normal", + }, + lsp_outgoing_calls = { + initial_mode = "normal", + }, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + }, }, }) require("telescope").load_extension("fzf") require("telescope").load_extension("ui-select") - - local b = require("telescope.builtin") - - map.n("B", b.builtin) - map.n("/", b.live_grep) - map.n("?", b.grep_string) - map.n("f", function() - b.find_files({ - find_command = { - "fd", - "--type", - "file", - "--follow", - "--hidden", - "--exclude", - ".git", - }, - }) - end) - map.n("b", function() - b.buffers({ sort_lastused = true, initial_mode = "normal" }) - end) - - map.n("t", b.treesitter) - - map.n("c", b.commands) - map.n("h", b.help_tags) - map.n("m", b.man_pages) - map.n("k", b.keymaps) - map.n("Q", function() - b.quickfix({ initial_mode = "normal" }) - end) - map.n("L", function() - b.loclist({ initial_mode = "normal" }) - end) - map.n("R", function() - b.registers({ initial_mode = "normal" }) - end) - map.n("A", b.autocommands) - + require("telescope").load_extension("refactoring") vim.api.nvim_create_autocmd("LspAttach", { callback = function(event) - local bnmap = function(keys, func) - map.n(keys, func, { buffer = event.buf }) + local b = require("telescope.builtin") + local bnmap = function(keys, func, desc) + vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) end - bnmap("gd", function() - b.lsp_definitions({ initial_mode = "normal" }) - end) + bnmap("gd", b.lsp_definitions, "[G]oto [D]efinition") bnmap("gvd", function() - b.lsp_definitions({ initial_mode = "normal", jump_type = "vsplit" }) - end) + b.lsp_definitions({ jump_type = "vsplit" }) + end, "[G]oto in a [V]ertical split to [D]efinition") bnmap("gxd", function() - b.lsp_definitions({ initial_mode = "normal", jump_type = "split" }) - end) + b.lsp_definitions({ jump_type = "split" }) + end, "[G]oto in a [X]horizontal split to [D]efinition") bnmap("gtd", function() - b.lsp_definitions({ initial_mode = "normal", jump_type = "tab" }) - end) - bnmap("gi", function() - b.lsp_implementations({ initial_mode = "normal" }) - end) - bnmap("gvi", function() - b.lsp_implementations({ initial_mode = "normal", jump_type = "vsplit" }) - end) - bnmap("gxi", function() - b.lsp_implementations({ initial_mode = "normal", jump_type = "split" }) - end) - bnmap("gti", function() - b.lsp_implementations({ initial_mode = "normal", jump_type = "tab" }) - end) - bnmap("go", b.lsp_document_symbols) - bnmap("gS", b.lsp_dynamic_workspace_symbols) - bnmap("ge", function() - b.lsp_document_diagnostics({ initial_mode = "normal" }) - end) - bnmap("gE", function() - b.lsp_workspace_diagnostics({ initial_mode = "normal" }) - end) - bnmap("gr", function() - b.lsp_references({ initial_mode = "normal" }) - end) - bnmap("gic", function() - b.lsp_incoming_calls({ initial_mode = "normal" }) - end) - bnmap("goc", function() - b.lsp_outgoing_calls({ initial_mode = "normal" }) - end) + b.lsp_definitions({ jump_type = "tab" }) + end, "[G]oto in a [T]ab to [D]efinition") + bnmap("D", b.lsp_type_definitions, "Type [D]efinition") + bnmap("vD", function() + b.lsp_type_definitions({ jump_type = "vsplit" }) + end, "Open in a [V]ertical split Type [D]efinition") + bnmap("xD", function() + b.lsp_type_definitions({ jump_type = "split" }) + end, "Open in a [X]horizontal split Type [D]efinition") + bnmap("tD", function() + b.lsp_type_definitions({ jump_type = "tab" }) + end, "Open in a [T]ab Type [D]efinition") + bnmap("gri", b.lsp_implementations, "[G]oto [I]mplementation") + bnmap("grvi", function() + b.lsp_implementations({ jump_type = "vsplit" }) + end, "[G]oto in a [V]ertical split to [I]mplementation") + bnmap("grxi", function() + b.lsp_implementations({ jump_type = "split" }) + end, "[G]oto in a [X]horizontal split to [I]mplementation") + bnmap("grti", function() + b.lsp_implementations({ jump_type = "tab" }) + end, "[G]oto in a [T]ab to [I]mplementation") + bnmap("grr", b.lsp_references, "[G]oto [R]eferences") + bnmap("ic", b.lsp_incoming_calls, "[I]ncoming [C]alls") + bnmap("oc", b.lsp_outgoing_calls, "[O]utgoing [C]alls") + bnmap("gO", b.lsp_document_symbols, "d[O]ocument symbols") + bnmap( + "ws", + b.lsp_dynamic_workspace_symbols, + "[W]orkspace [S]ymbols" + ) end, }) end, @@ -134,6 +346,7 @@ return { build = "make", }, "nvim-telescope/telescope-ui-select.nvim", + "ThePrimeagen/refactoring.nvim", }, }, } diff --git a/home/.config/nvim/lua/custom/plugins/ts.lua b/home/.config/nvim/lua/custom/plugins/ts.lua index c2741e5..40b1209 100644 --- a/home/.config/nvim/lua/custom/plugins/ts.lua +++ b/home/.config/nvim/lua/custom/plugins/ts.lua @@ -1,155 +1,155 @@ return { { - 'nvim-treesitter/nvim-treesitter', + "aaronik/treewalker.nvim", + keys = { + { + "", + "Treewalker Up", + { "n", "v" }, + silent = true, + desc = "Moves up to the previous neighbor node", + }, + { + "", + "Treewalker Down", + { "n", "v" }, + silent = true, + desc = "Moves up to the next neighbor node", + }, + { + "", + "Treewalker Left", + { "n", "v" }, + silent = true, + desc = "Moves to the first ancestor node that's on a different line from the current node", + }, + { + "", + "Treewalker Right", + { "n", "v" }, + silent = true, + desc = "Moves to the next node down that's indented further than the current node", + }, + { + "Treewalker SwapUp", + "", + silent = true, + desc = "Swaps the highest node on the line upwards in the document", + }, + { + "", + "Treewalker SwapDown", + silent = true, + desc = "Swaps the biggest node on the line downward in the document", + }, + { + "", + "Treewalker SwapLeft", + silent = true, + desc = "Swap the node under the cursor with its previous neighbor", + }, + { + "", + "Treewalker SwapRight", + silent = true, + desc = "Swap the node under the cursor with its next neighbor", + }, + }, + opts = {}, + }, + { + "nvim-treesitter/nvim-treesitter", + branch = "main", + lazy = false, dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - "nvim-treesitter/nvim-treesitter-refactor", - "theHamsta/crazy-node-movement", - "theHamsta/nvim-treesitter-pairs", - "RRethy/nvim-treesitter-endwise", + -- "theHamsta/nvim-treesitter-pairs", -- Reneable once main branch is supported + { + "LiadOz/nvim-dap-repl-highlights", + opts = {}, + }, }, build = ":TSUpdate", config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "bash", - "c", - "cmake", - "comment", - "cpp", - "css", - "diff", - "dockerfile", - "doxygen", - "fortran", - "git_config", - "git_rebase", - "gitattributes", - "gitcommit", - "gitignore", - "gpg", - "html", - "http", - "ini", - "javascript", - "jsdoc", - "json", - "jsonc", - "llvm", - "lua", - "luadoc", - "luap", - "make", - "markdown", - "markdown_inline", - "python", - "regex", - "rust", - "sql", - "tablegen", - "todotxt", - "toml", - "typescript", - "vim", - "vimdoc", - "xml", - "yaml", - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, - }, - indent = { enable = true }, - refactor = { - highlight_definitions = { enable = true }, - highlight_current_scope = { enable = true }, - }, - textobjects = { - select = { - enable = true, - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - swap = { - enable = true, - swap_next = { ["a"] = "@parameter.inner" }, - swap_previous = { ["A"] = "@parameter.inner" }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer", - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer", - }, - }, - lsp_interop = { - enable = true, - peek_definition_code = { - ["df"] = "@function.outer", - ["dF"] = "@class.outer", - }, - }, - }, - matchup = { - enable = true, - }, - pairs = { - enable = true, - goto_right_end = false, - keymaps = { goto_partner = "%" }, - }, - node_movement = { - enable = true, - keymaps = { - move_up = "", - move_down = "", - move_left = "", - move_right = "", - swap_left = "", -- will only swap when one of "swappable_textobjects" is selected - swap_right = "", - select_current_node = "", - }, - swappable_textobjects = { '@function.outer', '@parameter.inner', '@statement.outer' }, - allow_switch_parents = true, -- more craziness by switching parents while staying on the same level, false prevents you from accidentally jumping out of a function - allow_next_parent = true, -- more craziness by going up one level if next node does not have children - }, - tree_docs = { - enable = true, - }, - endwise = { - enable = true, - }, + require("nvim-treesitter").install({ + "awk", + "bash", + "c", + "cmake", + "comment", + "cpp", + "css", + "csv", + "diff", + "dockerfile", + "dap_repl", + "doxygen", + "editorconfig", + "fortran", + "git_config", + "git_rebase", + "gitattributes", + "gitcommit", + "gitignore", + "groovy", + "gpg", + "hlsplaylist", + "html", + "http", + "ini", + "javascript", + "jq", + "jsdoc", + "json", + "jsonc", + "just", + "llvm", + "lua", + "luadoc", + "luap", + "make", + "markdown", + "markdown_inline", + "query", + "passwd", + "printf", + "python", + "regex", + "readline", + "requirements", + "rust", + "sql", + "ssh_config", + "strace", + "sxhkdrc", + "tablegen", + "tmux", + "todotxt", + "toml", + "typescript", + "vim", + "vimdoc", + "xcompose", + "xml", + "xresources", + "yaml", + }) + end, + }, + "RRethy/nvim-treesitter-endwise", + { "nvim-treesitter/nvim-treesitter-context", opts = {} }, + { + "JoosepAlviste/nvim-ts-context-commentstring", + config = function() + require("ts_context_commentstring").setup({ + enable_autocmd = false, }) - end + local get_option = vim.filetype.get_option + + vim.filetype.get_option = function(filetype, option) + return option == "commentstring" + and require("ts_context_commentstring.internal").calculate_commentstring() + or get_option(filetype, option) + end + end, }, - "nvim-treesitter/nvim-treesitter-context", } diff --git a/home/.config/nvim/lua/custom/plugins/ui.lua b/home/.config/nvim/lua/custom/plugins/ui.lua index ba9d4ac..a07eda8 100644 --- a/home/.config/nvim/lua/custom/plugins/ui.lua +++ b/home/.config/nvim/lua/custom/plugins/ui.lua @@ -1,24 +1,16 @@ return { { - "sainnhe/gruvbox-material", + "ellisonleao/gruvbox.nvim", priority = 1000, config = function() - vim.g.gruvbox_material_background = "hard" - vim.g.gruvbox_material_enable_bold = 1 - vim.g.gruvbox_material_enable_italic = 1 - vim.g.gruvbox_material_better_performance = 1 - vim.g.gruvbox_material_palette = "original" - - vim.cmd([[ colorscheme gruvbox-material]]) - end - }, - { - "norcalli/nvim-colorizer.lua", - event = "BufRead", - config = true + require("gruvbox").setup({}) + vim.o.background = "dark" + vim.cmd([[colorscheme gruvbox]]) + end, }, { "lukas-reineke/indent-blankline.nvim", + event = "BufRead", config = function() local highlight = { "RainbowRed", @@ -29,7 +21,7 @@ return { "RainbowViolet", "RainbowCyan", } - local hooks = require "ibl.hooks" + local hooks = require("ibl.hooks") -- create the highlight groups in the highlight setup hook, so they are reset -- every time the colorscheme changes hooks.register(hooks.type.HIGHLIGHT_SETUP, function() @@ -43,38 +35,57 @@ return { end) vim.g.rainbow_delimiters = { highlight = highlight } - require("ibl").setup { scope = { highlight = highlight } } + require("ibl").setup({ + scope = { highlight = highlight }, + }) - hooks.register(hooks.type.SCOPE_HIGHLIGHT, - hooks.builtin.scope_highlight_from_extmark) - end + hooks.register( + hooks.type.SCOPE_HIGHLIGHT, + hooks.builtin.scope_highlight_from_extmark + ) + end, }, { - 'nvim-lualine/lualine.nvim', + "nvim-lualine/lualine.nvim", opts = { options = { icons_enabled = false, - theme = 'gruvbox_dark', - component_separators = '', - section_separators = '|', + theme = "gruvbox_dark", + component_separators = "", + section_separators = "|", + disabled_filetypes = { + winbar = { + "dap-view", + "dap-repl", + "dap-view-term", + }, + }, }, sections = { - lualine_a = { 'filetype', { 'filename', path = 1 } }, - lualine_b = { '%l/%L:%c:%o' }, - lualine_c = { 'diff' }, - lualine_x = { 'searchcount, selectioncount' }, - lualine_y = {}, - lualine_z = { 'diagnostics' } + lualine_a = { "filetype", { "filename", path = 1 } }, + lualine_b = { "%l/%L:%c:%o" }, + lualine_c = { "diff" }, + lualine_x = { "searchcount, selectioncount" }, + lualine_y = { "overseer", "copilot" }, + lualine_z = { "diagnostics" }, }, inactive_sections = { lualine_a = {}, lualine_b = {}, - lualine_c = { 'filename' }, + lualine_c = { "filename" }, lualine_x = {}, lualine_y = {}, - lualine_z = {} + lualine_z = {}, }, }, + dependencies = { + "AndreM222/copilot-lualine", + }, + }, + { + "jake-stewart/auto-cmdheight.nvim", + lazy = false, + opts = {}, }, - "https://gitlab.com/HiPhish/rainbow-delimiters.nvim", + -- "https://gitlab.com/HiPhish/rainbow-delimiters.nvim", } diff --git a/home/.config/nvim/lua/mapper.lua b/home/.config/nvim/lua/mapper.lua deleted file mode 100644 index c31aeca..0000000 --- a/home/.config/nvim/lua/mapper.lua +++ /dev/null @@ -1,84 +0,0 @@ -local M = {} - -M.map = function(mode, keys, action, opts, bufnr) - opts = vim.tbl_extend("force", { silent = true, buffer = bufnr }, opts or {}) - vim.keymap.set(mode, keys, action, opts) -end - -M.cmdi = function(mode, keys, action, opts, bufnr) - opts = vim.tbl_extend("force", { silent = false }, opts or {}) - M.map(mode, keys, ":" .. action, opts, bufnr) -end - -M.cmd = function(mode, keys, action, opts, bufnr) - M.map(mode, keys, "" .. action .. "", opts, bufnr) -end - -M.plug = function(mode, keys, action, opts, bufnr) - M.map(mode, keys, "" .. action, opts, bufnr) -end - -M.n = function(keys, action, opts, bufnr) - M.map("n", keys, action, opts, bufnr) -end -M.ncmdi = function(keys, action, opts, bufnr) - M.cmdi("n", keys, action, opts, bufnr) -end -M.ncmd = function(keys, action, opts, bufnr) - M.cmd("n", keys, action, opts, bufnr) -end -M.nplug = function(keys, action, opts, bufnr) - M.plug("n", keys, "(" .. action .. ")", opts, bufnr) -end - -M.v = function(keys, action, opts, bufnr) - M.map("v", keys, action, opts, bufnr) -end -M.vcmdi = function(keys, action, opts, bufnr) - opts = vim.tbl_extend("force", { silent = false }, opts or {}) - M.v(keys, ":" .. action, opts, bufnr) -end -M.vcmd = function(keys, action, opts, bufnr) - M.vcmdi(keys, action .. "", opts, bufnr) -end -M.vplug = function(keys, action, opts, bufnr) - M.plug("v", keys, "(" .. action .. ")", opts, bufnr) -end - -M.nv = function(keys, action, opts, bufnr) - M.map({ "n", "v" }, keys, action, opts, bufnr) -end -M.nvcmdi = function(keys, action, opts, bufnr) - M.ncmdi(keys, action, opts, bufnr) - M.vcmdi(keys, action, opts, bufnr) -end -M.nvcmd = function(keys, action, opts, bufnr) - M.ncmd(keys, action, opts, bufnr) - M.vcmd(keys, action, opts, bufnr) -end -M.nvplug = function(keys, action, opts, bufnr) - M.plug({ "n", "v" }, keys, "(" .. action .. ")", opts, bufnr) -end - -M.i = function(keys, action, opts, bufnr) - M.map("i", keys, action, opts, bufnr) -end -M.iplug = function(keys, action, opts, bufnr) - opts = vim.tbl_extend("force", { silent = false }, opts or {}) - M.plug("i", keys, action, opts, bufnr) -end - -M.t = function(keys, action, opts, bufnr) - M.map("t", keys, action, opts, bufnr) -end -M.tcmdi = function(keys, action, opts, bufnr) - M.cmdi("t", keys, action, opts, bufnr) -end -M.tcmd = function(keys, action, opts, bufnr) - M.cmd("t", keys, action, opts, bufnr) -end -M.tplug = function(keys, action, opts, bufnr) - M.plug("t", keys, action, opts, bufnr) -end - -return M diff --git a/home/.config/pacman/makepkg.conf b/home/.config/pacman/makepkg.conf index 5c452e9..383ba6d 100644 --- a/home/.config/pacman/makepkg.conf +++ b/home/.config/pacman/makepkg.conf @@ -1,6 +1,6 @@ CFLAGS="-march=native -Ofast -pipe -fomit-frame-pointer" RUSTFLAGS="-C opt-level=2 -C target-cpu=native" -MAKEFLAGS="-j$(nproc)" +MAKEFLAGS="-j4" BUILDDIR=/tmp/makepkg COMPRESSGZ=(pzip -c -f -n) COMPRESSBZ2=(pzip2 -c -f) diff --git a/home/.config/pam-gnupg b/home/.config/pam-gnupg index 0664d7c..b6deeb6 100644 --- a/home/.config/pam-gnupg +++ b/home/.config/pam-gnupg @@ -1,7 +1,10 @@ -91191A4A6E86279A901A7D38A7512EC126518FA5 -22747ABA1B4502F186654CD84DC353B0C3BD353F -9F3FCCA0F99AE1C5D05B834F0E89C79970A7B74A - +~/.local/share/gnupg +5110851E65983C892CC09B51B17F50B3073C3F13 613F4BBF6E877E8CF55E18C24A429474B2F1A6AD -3D9578DBF76FC0D4272965CE8B3B04B7521AAD66 +91191A4A6E86279A901A7D38A7512EC126518FA5 +E9B1DBA60EEF1FCCDC1C230A269E1F5CBC1E27E1 23F3B67A62967CE2538EF1748CC3D4321A08F6BC +9F3FCCA0F99AE1C5D05B834F0E89C79970A7B74A +8325D272CCC3E0582A84CCCDC6659A146BA56581 +61B366B27B83FB1CC5A789C578CB6103830506E3 +515584E3A76C03EEA4A563156882938003FBEC90 diff --git a/home/.config/sh/aliases b/home/.config/sh/aliases index dcff035..3c50636 100644 --- a/home/.config/sh/aliases +++ b/home/.config/sh/aliases @@ -9,7 +9,7 @@ whichkey() { } alias sudo='doas' -alias sudoedit='doas nvim' +alias sudoedit='doasedit' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' @@ -26,8 +26,6 @@ alias g='git' alias sys='systemctl' alias ssys='doas systemctl' alias sysu='systemctl --user' -alias sst='systemctl status' -alias syse='doas systemctl edit' alias gimme='doas chown $USER:$(id -gn $USER)' alias free='free -h' @@ -70,3 +68,4 @@ alias astcc='clang -Xclang -ast-dump -fsyntax-only' alias astfc='flang-new -fc1 -fdebug-dump-parse-tree' alias gdb='gdb -ex start --args' +alias j='just' diff --git a/home/.config/sh/envrc b/home/.config/sh/envrc index d06a12f..ec75d82 100644 --- a/home/.config/sh/envrc +++ b/home/.config/sh/envrc @@ -1,7 +1,8 @@ #! /bin/sh if [ -z "$ENV_SOURCED" ]; then - export ENV_SOURCED="$0" + export PATH="$HOME"/.local/bin:"$PATH" + export ENV_SOURCED="$0" fi safesource() { @@ -17,8 +18,6 @@ ifexists() { exists "$1" && "$@" } -export PATH="$HOME"/.local/bin:"$PATH" - case $TERM in *256color|*truecolor) export COLORTERM=24bit @@ -96,11 +95,11 @@ export LESS="-F -X $LESS" export LANG=en_US.UTF-8 export OPENER='xdg-open' -export FZF_DEFAULT_COMMAND="fd --type file --follow --hidden --exclude .git" +export FZF_DEFAULT_COMMAND="fd --type file --follow --hidden --exclude .git --color=always" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" -export FZF_DIRS_COMMAND="fd --type d --follow --hidden --exclude .git" -export FZF_DEFAULT_OPTS="--layout=reverse --inline-info --cycle --color=dark --color=fg:-1,bg:-1,hl:#5fff87,fg+:-1,bg+:-1,hl+:#ffaf5f --color=info:#af87ff,prompt:#5fff87,pointer:#ff87d7,marker:#ff87d7,spinner:#ff87d7" -export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200' --select-1 --exit-0" +export FZF_DIRS_COMMAND="fd --type d --follow --hidden --exclude .git --color=always" +export FZF_DEFAULT_OPTS="--ansi --layout=reverse --inline-info --cycle --color=dark --color=fg:-1,bg:-1,hl:#5fff87,fg+:-1,bg+:-1,hl+:#ffaf5f --color=info:#af87ff,prompt:#5fff87,pointer:#ff87d7,marker:#ff87d7,spinner:#ff87d7" +export FZF_CTRL_T_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {}' 2> /dev/null | head -200' --select-1 --exit-0" export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview' --sort --exact" export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'" @@ -151,55 +150,44 @@ export GIT_PS1_HIDE_IF_PWD_IGNORED=1 export DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock" -if [ "$(uname -n)" = "hercules" ]; then - export OCL_ICD_VENDORS=nvidia - # shellcheck source=/dev/null - [ -r ~/.config/sh/envrc ] && . ~/.config/sh/work-envrc -fi - # https://github.com/sparrowwallet/sparrow/issues/170#issuecomment-896866817 export GDK_DISPLAY=1 # cleanup ~ -export GTK_RC_FILES="$XDG_CONFIG_HOME/gtk-1.0/gtkrc" +# https://wiki.archlinux.org/title/XDG_Base_Directory#Partial +export ALTUSERXSESSION="$XDG_CACHE_HOME/x11/Xsession" +export CARGO_HOME="$XDG_DATA_HOME/cargo" +export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" +export ERRFILE="$XDG_CACHE_HOME/x11/xsession-errors" +export GNUPGHOME="$XDG_DATA_HOME/gnupg" +export GOPATH="$XDG_DATA_HOME/go" +export GRADLE_USER_HOME="$XDG_DATA_HOME/gradle" export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" -export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" +export GTK_RC_FILES="$XDG_CONFIG_HOME/gtk-1.0/gtkrc" export INPUTRC="$XDG_CONFIG_HOME/sh/inputrc" -export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export NODE_REPL_HISTORY="$XDG_DATA_HOME/node_repl_history" export PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store" -export GNUPGHOME="$XDG_DATA_HOME/gnupg" -export LESSHISTFILE="-" -export BASH_COMPLETION_USER_FILE="$XDG_CONFIG_HOME/bash-completion/bash_completion" -export CARGO_HOME="$XDG_DATA_HOME/cargo" -export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" -export LESSKEY="$XDG_CONFIG_HOME/less/lesskey" -export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo":/usr/share/terminfo -export IPYTHONDIR="$XDG_CONFIG_HOME/ipython" -export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" export PYTHON_EGG_CACHE="$XDG_CACHE_HOME/python-eggs" +export RUFF_CACHE_DIR=$XDG_CACHE_HOME/ruff export RUSTUP_HOME="$XDG_DATA_HOME/rustup" -export TMUX_TMPDIR="$XDG_RUNTIME_DIR" -export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default" -export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" -export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" -export CCACHE_CONFIGPATH="$XDG_CONFIG_HOME/ccache.config" -export CCACHE_DIR="$XDG_CACHE_HOME/ccache" export RUSTUP_HOME="$XDG_DATA_HOME/rustup" -export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/ripgreprc" -export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" -export MACHINE_STORAGE_PATH="$XDG_DATA_HOME/docker-machine" -export GOPATH="$XDG_DATA_HOME/go" -export GRADLE_USER_HOME="$XDG_DATA_HOME/gradle" -export XCOMPOSEFILE="$XDG_CONFIG_HOME/X11/xcompose" -export XCOMPOSECACHE="$XDG_CACHE_HOME/X11/xcompose" -export NODE_REPL_HISTORY="$XDG_DATA_HOME/node_repl_history" -export NVM_DIR="$XDG_DATA_HOME/nvm" -export WORKON_HOME="$XDG_DATA_HOME/virtualenvs" export USERXSESSION="$XDG_CACHE_HOME/x11/xsession" export USERXSESSIONRC="$XDG_CACHE_HOME/x11/xsessionrc" -export ALTUSERXSESSION="$XDG_CACHE_HOME/x11/Xsession" -export ERRFILE="$XDG_CACHE_HOME/x11/xsession-errors" +export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" +export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default" +export WORKON_HOME="$XDG_DATA_HOME/virtualenvs" +export XCOMPOSECACHE="$XDG_CACHE_HOME/X11/xcompose" +export XCOMPOSEFILE="$XDG_CONFIG_HOME/X11/xcompose" +export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" +export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" unset SSH_AGENT_PID SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" export SSH_AUTH_SOCK + +if [ "$(uname -n)" = "hercules" ]; then + export OCL_ICD_VENDORS=nvidia + # shellcheck source=/dev/null + [ -r ~/.config/sh/envrc ] && . ~/.config/sh/work-envrc +fi diff --git a/home/.config/sxhkd/sxhkdrc b/home/.config/sxhkd/sxhkdrc index 11c5192..fed8604 100644 --- a/home/.config/sxhkd/sxhkdrc +++ b/home/.config/sxhkd/sxhkdrc @@ -1,3 +1,4 @@ +# vim set ft=sxhkdrc super+Return $TERMINAL @@ -8,7 +9,10 @@ super+r rofi -show run super+d - cd ~/dotfiles && eval $FZF_DEFAULT_COMMAND | rofi -width 90 -dmenu -p dotfiles | xargs -d '\n' -r $TERMINAL -e $EDITOR + cd ~/dotfiles && fd --type file --follow --hidden --exclude .git | rofi -width 90 -dmenu -p dotfiles | xargs -d '\n' -r $TERMINAL -e $EDITOR + +super+D + cd ~/doxfiles && fd --type file --follow --hidden --exclude .git | rofi -width 90 -dmenu -p doxfiles | xargs -d '\n' -r $TERMINAL -e $EDITOR super+a rofi -modi windowcd -show windowcd diff --git a/home/.config/tmux/tmux.conf b/home/.config/tmux/tmux.conf index b3ebcfb..9520d26 100644 --- a/home/.config/tmux/tmux.conf +++ b/home/.config/tmux/tmux.conf @@ -1,11 +1,20 @@ +set -ga update-environment EDITOR + # List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' set -g @plugin 'tmux-plugins/tmux-pain-control' set -g @plugin 'tmux-plugins/tmux-copycat' +set -g @plugin 'tmux-plugins/tmux-open' +set -g @plugin 'tmux-plugins/tmux-sessionist' set -g @plugin 'tmux-plugins/tmux-yank' -set -g @plugin 'tmux-plugins/tmux-urlview' -set -g @plugin 'lawabidingcactus/tmux-gruvbox-truecolor' +set -g @plugin 'nhdaly/tmux-better-mouse-mode' +set -g @plugin 'rickstaa/tmux-notify' +set -g @plugin 'egel/tmux-gruvbox' +set -g @plugin 'artemave/tmux_super_fingers' +set -g @plugin 'aserowy/tmux.nvim' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-continuum' unbind C-b set -g prefix ` @@ -14,6 +23,7 @@ set -g prefix2 C-Space set -g base-index 1 setw -g mode-keys vi +set-option -g mouse on bind-key R run-shell 'tmux source-file ~/.config/tmux/tmux.conf > /dev/null; \ tmux display-message "Sourced tmux.conf!"' @@ -29,24 +39,11 @@ bind-key -T copy-mode-vi 'y' send -X copy-selection bind-key -T copy-mode-vi 'C-e' send -X end-of-line bind-key -T copy-mode-vi 'C-a' send -X start-of-line -is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" - -bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1' -bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1' -bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1' -bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1' - -bind-key -T copy-mode-vi M-h resize-pane -L 1 -bind-key -T copy-mode-vi M-j resize-pane -D 1 -bind-key -T copy-mode-vi M-k resize-pane -U 1 -bind-key -T copy-mode-vi M-l resize-pane -R 1 - set-option -g default-shell $SHELL -#set -g default-terminal tmux-256color -#set -sa terminal-overrides ",tmux-256color:Tc" -set -g default-terminal "alacritty" -set-option -sa terminal-overrides ",alacritty*:Tc" +set -g default-terminal "tmux-256color" +set -as terminal-features ",alacritty*:RGB" +set -ga terminal-features "*:hyperlinks" ## update the TERM variable of terminal emulator when creating a new session or attaching a existing session set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM COLORTERM' @@ -57,10 +54,21 @@ set -g set-titles-string "#T" set -g automatic-rename-format "#{?pane_in_mode,[tmux],#{?#{==:#{pane_current_command},zsh}, #{b:pane_current_path}, #{b:pane_current_path}:#{pane_current_command}}}#{?pane_dead,[dead],}" set-option -g renumber-windows on -#https://github.com/neovim/neovim/wiki/FAQ#esc-in-tmux-or-gnu-screen-is-delayed -set -sg escape-time 0 -set -g focus-events on +set -g @tmux-gruvbox 'dark' +set -g @tmux-gruvbox-statusbar-alpha 'true' +set -g @tmux-gruvbox-right-status-z '#h C:#{continuum_status}' + +set -g @yank_selection_mouse 'clipboard' +set -g @yank_action 'copy-pipe' + +set -g @tmux-nvim-condition "ps -t '#{pane_tty}' -o state= -o args= | grep -iqE '^[^TXZ ]+ .*g?(view|n?vim?x?|fzf)(diff)?'" + +set -g @continuum-restore 'on' +set -g @continuum-save-interval '5' +set -g @resurrect-strategy-nvim 'session' +set -g @resurrect-capture-pane-contents 'on' +set -g @resurrect-processes 'ssh "git log" "just n" "just nvim" "just e" "just edit" lf aerc bat difft delta' set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.local/share/tmux/plugins' if "test ! -d ~/.local/share/tmux/plugins/tpm" \ diff --git a/home/.config/zsh/.zshrc b/home/.config/zsh/.zshrc index 614e7f0..59d7fad 100644 --- a/home/.config/zsh/.zshrc +++ b/home/.config/zsh/.zshrc @@ -171,6 +171,9 @@ set zle_bracketed_paste # Explicitly restore this zsh default autoload -Uz bracketed-paste-magic zle -N bracketed-paste bracketed-paste-magic +autoload -Uz select-word-style +select-word-style shell + safesource /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh if [ -n "$ZSH_HIGHLIGHT_STYLES" ]; then @@ -184,8 +187,7 @@ bindkey '^[[Z' autosuggest-accept safesource /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh -safesource /etc/profile.d/fzf.zsh || safesource /usr/share/fzf/key-bindings.zsh -safesource /usr/share/zsh/site-functions/_fzf || safesource /usr/share/fzf/completion.zsh +source <(fzf --zsh) fzf-history-widget-accept() { fzf-history-widget @@ -193,3 +195,26 @@ fzf-history-widget-accept() { } zle -N fzf-history-widget-accept bindkey '^X^R' fzf-history-widget-accept + +_fzf_compgen_path() { + fd --hidden --follow --exclude ".git" . "$1" +} + +# Use fd to generate the list for directory completion +_fzf_compgen_dir() { + fd --type d --hidden --follow --exclude ".git" . "$1" +} + +compdef g=git +compdef j=just +compdef n=nvim +compdef ndiff=nvim +compdef nd=nvim +compdef nview=nvim +compdef nv=nvim +compdef sys=systemctl +compdef ssys=systemctl +compdef sysu=systemctl +compdef l=lsd +compdef la=lsd +compdef lt=lsd -- cgit v1.2.3-70-g09d2