mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-05-19 21:16:51 +02:00
refactor: dependencies for both emacs & neovim
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
# ==============================================
|
||||
# Based on doomemacs's auther's config:
|
||||
# https://github.com/hlissner/dotfiles/blob/master/modules/editors/emacs.nix
|
||||
#
|
||||
# Emacs Tutorials:
|
||||
# 1. Official: <https://www.gnu.org/software/emacs/tour/index.html>
|
||||
# 2. Doom Emacs: <https://github.com/doomemacs/doomemacs/blob/master/docs/index.org>
|
||||
#
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
doomemacs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.editors.emacs;
|
||||
envExtra = ''
|
||||
export PATH="$XDG_CONFIG_HOME/emacs/bin:$PATH"
|
||||
'';
|
||||
shellAliases = {
|
||||
e = "emacs";
|
||||
ediff = ''emacs -nw --eval "(ediff-files \"$1\" \"$2\")"'';
|
||||
eman = ''emacs -nw --eval "(switch-to-buffer (man \"$1\"))"'';
|
||||
};
|
||||
in {
|
||||
options.modules.editors.emacs = {
|
||||
enable = mkEnableOption "Emacs Editor";
|
||||
doom = {
|
||||
enable = mkEnableOption "Doom Emacs";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = with pkgs; [
|
||||
## Emacs itself
|
||||
binutils # native-comp needs 'as', provided by this
|
||||
# 28.2 + native-comp
|
||||
((emacsPackagesFor emacs-unstable-nox).emacsWithPackages
|
||||
(epkgs: [epkgs.vterm]))
|
||||
emacs-all-the-icons-fonts
|
||||
|
||||
## Doom dependencies
|
||||
git
|
||||
(ripgrep.override {withPCRE2 = true;})
|
||||
gnutls # for TLS connectivity
|
||||
|
||||
## Optional dependencies
|
||||
fd # faster projectile indexing
|
||||
imagemagick # for image-dired
|
||||
zstd # for undo-fu-session/undo-tree compression
|
||||
|
||||
## Module dependencies
|
||||
# :checkers spell
|
||||
(aspellWithDicts (ds: with ds; [en en-computers en-science]))
|
||||
# :tools editorconfig
|
||||
editorconfig-core-c # per-project style config
|
||||
# :tools lookup & :lang org +roam
|
||||
sqlite
|
||||
# :lang latex & :lang org (latex previews)
|
||||
texlive.combined.scheme-medium
|
||||
];
|
||||
|
||||
programs.bash.bashrcExtra = envExtra;
|
||||
programs.zsh.envExtra = envExtra;
|
||||
home.shellAliases = shellAliases;
|
||||
programs.nushell.shellAliases = shellAliases;
|
||||
|
||||
# allow fontconfig to discover fonts and configurations installed through `home.packages`
|
||||
fonts.fontconfig.enable = true;
|
||||
|
||||
xdg.configFile."doom".source = ./doom;
|
||||
|
||||
home.activation = mkIf cfg.doom.enable {
|
||||
installDoomEmacs = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; Place your private configuration here! Remember, you do not need to run 'doom
|
||||
;; sync' after modifying this file!
|
||||
|
||||
|
||||
;; Some functionality uses this to identify you, e.g. GPG configuration, email
|
||||
;; clients, file templates and snippets. It is optional.
|
||||
;; (setq user-full-name "John Doe"
|
||||
;; user-mail-address "john@doe.com")
|
||||
|
||||
;; Doom exposes five (optional) variables for controlling fonts in Doom:
|
||||
;;
|
||||
;; - `doom-font' -- the primary font to use
|
||||
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
|
||||
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
|
||||
;; presentations or streaming.
|
||||
;; - `doom-symbol-font' -- for symbols
|
||||
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
|
||||
;;
|
||||
;; See 'C-h v doom-font' for documentation and more examples of what they
|
||||
;; accept. For example:
|
||||
;;
|
||||
;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light)
|
||||
;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13))
|
||||
;;
|
||||
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
|
||||
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
|
||||
;; refresh your font settings. If Emacs still can't find your font, it likely
|
||||
;; wasn't installed correctly. Font issues are rarely Doom issues!
|
||||
|
||||
;; There are two ways to load a theme. Both assume the theme is installed and
|
||||
;; available. You can either set `doom-theme' or manually load a theme with the
|
||||
;; `load-theme' function. This is the default:
|
||||
(setq doom-theme 'doom-one)
|
||||
|
||||
;; This determines the style of line numbers in effect. If set to `nil', line
|
||||
;; numbers are disabled. For relative line numbers, set this to `relative'.
|
||||
(setq display-line-numbers-type t)
|
||||
|
||||
;; If you use `org' and don't want your org files in the default location below,
|
||||
;; change `org-directory'. It must be set before org loads!
|
||||
(setq org-directory "~/org/")
|
||||
|
||||
|
||||
;; Whenever you reconfigure a package, make sure to wrap your config in an
|
||||
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
|
||||
;;
|
||||
;; (after! PACKAGE
|
||||
;; (setq x y))
|
||||
;;
|
||||
;; The exceptions to this rule:
|
||||
;;
|
||||
;; - Setting file/directory variables (like `org-directory')
|
||||
;; - Setting variables which explicitly tell you to set them before their
|
||||
;; package is loaded (see 'C-h v VARIABLE' to look up their documentation).
|
||||
;; - Setting doom variables (which start with 'doom-' or '+').
|
||||
;;
|
||||
;; Here are some additional functions/macros that will help you configure Doom.
|
||||
;;
|
||||
;; - `load!' for loading external *.el files relative to this one
|
||||
;; - `use-package!' for configuring packages
|
||||
;; - `after!' for running code after a package has loaded
|
||||
;; - `add-load-path!' for adding directories to the `load-path', relative to
|
||||
;; this file. Emacs searches the `load-path' when you load packages with
|
||||
;; `require' or `use-package'.
|
||||
;; - `map!' for binding new keys
|
||||
;;
|
||||
;; To get information about any of these functions/macros, move the cursor over
|
||||
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
|
||||
;; This will open documentation for it, including demos of how they are used.
|
||||
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
|
||||
;; etc).
|
||||
;;
|
||||
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
|
||||
;; they are implemented.
|
||||
@@ -0,0 +1,195 @@
|
||||
;;; init.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; This file controls what Doom modules are enabled and what order they load
|
||||
;; in. Remember to run 'doom sync' after modifying it!
|
||||
|
||||
;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
|
||||
;; documentation. There you'll find a link to Doom's Module Index where all
|
||||
;; of our modules are listed, including what flags they support.
|
||||
|
||||
;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or
|
||||
;; 'C-c c k' for non-vim users) to view its documentation. This works on
|
||||
;; flags as well (those symbols that start with a plus).
|
||||
;;
|
||||
;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its
|
||||
;; directory (for easy access to its source code).
|
||||
|
||||
(doom! :input
|
||||
;;bidi ; (tfel ot) thgir etirw uoy gnipleh
|
||||
;;chinese
|
||||
;;japanese
|
||||
;;layout ; auie,ctsrnm is the superior home row
|
||||
|
||||
:completion
|
||||
company ; the ultimate code completion backend
|
||||
;;helm ; the *other* search engine for love and life
|
||||
;;ido ; the other *other* search engine...
|
||||
;;ivy ; a search engine for love and life
|
||||
vertico ; the search engine of the future
|
||||
|
||||
:ui
|
||||
;;deft ; notational velocity for Emacs
|
||||
doom ; what makes DOOM look the way it does
|
||||
doom-dashboard ; a nifty splash screen for Emacs
|
||||
;;doom-quit ; DOOM quit-message prompts when you quit Emacs
|
||||
;;(emoji +unicode) ; 🙂
|
||||
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
|
||||
;;hydra
|
||||
;;indent-guides ; highlighted indent columns
|
||||
;;ligatures ; ligatures and symbols to make your code pretty again
|
||||
;;minimap ; show a map of the code on the side
|
||||
modeline ; snazzy, Atom-inspired modeline, plus API
|
||||
;;nav-flash ; blink cursor line after big motions
|
||||
neotree ; a project drawer, like NERDTree for vim
|
||||
ophints ; highlight the region an operation acts on
|
||||
(popup +defaults) ; tame sudden yet inevitable temporary windows
|
||||
;;tabs ; a tab bar for Emacs
|
||||
;;treemacs ; a project drawer, like neotree but cooler
|
||||
;;unicode ; extended unicode support for various languages
|
||||
(vc-gutter +pretty) ; vcs diff in the fringe
|
||||
vi-tilde-fringe ; fringe tildes to mark beyond EOB
|
||||
;;window-select ; visually switch windows
|
||||
workspaces ; tab emulation, persistence & separate workspaces
|
||||
;;zen ; distraction-free coding or writing
|
||||
|
||||
:editor
|
||||
(evil +everywhere); come to the dark side, we have cookies
|
||||
file-templates ; auto-snippets for empty files
|
||||
fold ; (nigh) universal code folding
|
||||
;;(format +onsave) ; automated prettiness
|
||||
;;god ; run Emacs commands without modifier keys
|
||||
;;lispy ; vim for lisp, for people who don't like vim
|
||||
;;multiple-cursors ; editing in many places at once
|
||||
;;objed ; text object editing for the innocent
|
||||
;;parinfer ; turn lisp into python, sort of
|
||||
;;rotate-text ; cycle region at point between text candidates
|
||||
snippets ; my elves. They type so I don't have to
|
||||
;;word-wrap ; soft wrapping with language-aware indent
|
||||
|
||||
:emacs
|
||||
dired ; making dired pretty [functional]
|
||||
electric ; smarter, keyword-based electric-indent
|
||||
;;ibuffer ; interactive buffer management
|
||||
undo ; persistent, smarter undo for your inevitable mistakes
|
||||
vc ; version-control and Emacs, sitting in a tree
|
||||
|
||||
:term
|
||||
;;eshell ; the elisp shell that works everywhere
|
||||
;;shell ; simple shell REPL for Emacs
|
||||
;;term ; basic terminal emulator for Emacs
|
||||
vterm ; the best terminal emulation in Emacs
|
||||
|
||||
:checkers
|
||||
syntax ; tasing you for every semicolon you forget
|
||||
(spell +flyspell) ; tasing you for misspelling mispelling
|
||||
grammar ; tasing grammar mistake every you make
|
||||
|
||||
:tools
|
||||
;;ansible
|
||||
;;biblio ; Writes a PhD for you (citation needed)
|
||||
;;collab ; buffers with friends
|
||||
;;debugger ; FIXME stepping through code, to help you add bugs
|
||||
;;direnv
|
||||
;;docker
|
||||
;;editorconfig ; let someone else argue about tabs vs spaces
|
||||
;;ein ; tame Jupyter notebooks with emacs
|
||||
(eval +overlay) ; run code, run (also, repls)
|
||||
;;gist ; interacting with github gists
|
||||
lookup ; navigate your code and its documentation
|
||||
lsp ; M-x vscode
|
||||
magit ; a git porcelain for Emacs
|
||||
;;make ; run make tasks from Emacs
|
||||
;;pass ; password manager for nerds
|
||||
;;pdf ; pdf enhancements
|
||||
;;prodigy ; FIXME managing external services & code builders
|
||||
;;rgb ; creating color strings
|
||||
;;taskrunner ; taskrunner for all your projects
|
||||
terraform ; infrastructure as code
|
||||
;;tmux ; an API for interacting with tmux
|
||||
tree-sitter ; syntax and parsing, sitting in a tree...
|
||||
;;upload ; map local to remote projects via ssh/ftp
|
||||
|
||||
:os
|
||||
(:if IS-MAC macos) ; improve compatibility with macOS
|
||||
;;tty ; improve the terminal Emacs experience
|
||||
|
||||
:lang
|
||||
;;agda ; types of types of types of types...
|
||||
;;beancount ; mind the GAAP
|
||||
(cc +lsp) ; C > C++ == 1
|
||||
;;clojure ; java with a lisp
|
||||
;;common-lisp ; if you've seen one lisp, you've seen them all
|
||||
;;coq ; proofs-as-programs
|
||||
;;crystal ; ruby at the speed of c
|
||||
;;csharp ; unity, .NET, and mono shenanigans
|
||||
data ; config/data formats
|
||||
;;(dart +flutter) ; paint ui and not much else
|
||||
;;dhall
|
||||
;;elixir ; erlang done right
|
||||
;;elm ; care for a cup of TEA?
|
||||
emacs-lisp ; drown in parentheses
|
||||
;;erlang ; an elegant language for a more civilized age
|
||||
;;ess ; emacs speaks statistics
|
||||
;;factor
|
||||
;;faust ; dsp, but you get to keep your soul
|
||||
;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER)
|
||||
;;fsharp ; ML stands for Microsoft's Language
|
||||
;;fstar ; (dependent) types and (monadic) effects and Z3
|
||||
;;gdscript ; the language you waited for
|
||||
(go +lsp) ; the hipster dialect
|
||||
;;(graphql +lsp) ; Give queries a REST
|
||||
;;(haskell +lsp) ; a language that's lazier than I am
|
||||
;;hy ; readability of scheme w/ speed of python
|
||||
;;idris ; a language you can depend on
|
||||
json ; At least it ain't XML
|
||||
(java +lsp) ; the poster child for carpal tunnel syndrome
|
||||
javascript ; all(hope(abandon(ye(who(enter(here))))))
|
||||
;;julia ; a better, faster MATLAB
|
||||
;;kotlin ; a better, slicker Java(Script)
|
||||
latex ; writing papers in Emacs has never been so fun
|
||||
;;lean ; for folks with too much to prove
|
||||
;;ledger ; be audit you can be
|
||||
lua ; one-based indices? one-based indices
|
||||
markdown ; writing docs for people to ignore
|
||||
;;nim ; python + lisp at the speed of c
|
||||
nix ; I hereby declare "nix geht mehr!"
|
||||
;;ocaml ; an objective camel
|
||||
org ; organize your plain life in plain text
|
||||
;;php ; perl's insecure younger brother
|
||||
;;plantuml ; diagrams for confusing people more
|
||||
;;purescript ; javascript, but functional
|
||||
python ; beautiful is better than ugly
|
||||
;;qt ; the 'cutest' gui framework ever
|
||||
;;racket ; a DSL for DSLs
|
||||
;;raku ; the artist formerly known as perl6
|
||||
;;rest ; Emacs as a REST client
|
||||
;;rst ; ReST in peace
|
||||
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
|
||||
(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
|
||||
;;scala ; java, but good
|
||||
(scheme +guile) ; a fully conniving family of lisps
|
||||
sh ; she sells {ba,z,fi}sh shells on the C xor
|
||||
;;sml
|
||||
;;solidity ; do you need a blockchain? No.
|
||||
;;swift ; who asked for emoji variables?
|
||||
;;terra ; Earth and Moon in alignment for performance.
|
||||
;;web ; the tubes
|
||||
yaml ; JSON, but readable
|
||||
;;zig ; C, but simpler
|
||||
|
||||
:email
|
||||
;;(mu4e +org +gmail)
|
||||
;;notmuch
|
||||
;;(wanderlust +gmail)
|
||||
|
||||
:app
|
||||
;;calendar
|
||||
;;emms
|
||||
;;everywhere ; *leave* Emacs!? You must be joking
|
||||
;;irc ; how neckbeards socialize
|
||||
;;(rss +org) ; emacs as an RSS reader
|
||||
;;twitter ; twitter client https://twitter.com/vnought
|
||||
|
||||
:config
|
||||
;;literate
|
||||
(default +bindings +smartparens))
|
||||
@@ -0,0 +1,50 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; $DOOMDIR/packages.el
|
||||
|
||||
;; To install a package with Doom you must declare them here and run 'doom sync'
|
||||
;; on the command line, then restart Emacs for the changes to take effect -- or
|
||||
;; use 'M-x doom/reload'.
|
||||
|
||||
|
||||
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
|
||||
;; (package! some-package)
|
||||
|
||||
;; To install a package directly from a remote git repo, you must specify a
|
||||
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
|
||||
;; https://github.com/radian-software/straight.el#the-recipe-format
|
||||
;; (package! another-package
|
||||
;; :recipe (:host github :repo "username/repo"))
|
||||
|
||||
;; If the package you are trying to install does not contain a PACKAGENAME.el
|
||||
;; file, or is located in a subdirectory of the repo, you'll need to specify
|
||||
;; `:files' in the `:recipe':
|
||||
;; (package! this-package
|
||||
;; :recipe (:host github :repo "username/repo"
|
||||
;; :files ("some-file.el" "src/lisp/*.el")))
|
||||
|
||||
;; If you'd like to disable a package included with Doom, you can do so here
|
||||
;; with the `:disable' property:
|
||||
;; (package! builtin-package :disable t)
|
||||
|
||||
;; You can override the recipe of a built in package without having to specify
|
||||
;; all the properties for `:recipe'. These will inherit the rest of its recipe
|
||||
;; from Doom or MELPA/ELPA/Emacsmirror:
|
||||
;; (package! builtin-package :recipe (:nonrecursive t))
|
||||
;; (package! builtin-package-2 :recipe (:repo "myfork/package"))
|
||||
|
||||
;; Specify a `:branch' to install a package from a particular branch or tag.
|
||||
;; This is required for some packages whose default branch isn't 'master' (which
|
||||
;; our package manager can't deal with; see radian-software/straight.el#279)
|
||||
;; (package! builtin-package :recipe (:branch "develop"))
|
||||
|
||||
;; Use `:pin' to specify a particular commit to install.
|
||||
;; (package! builtin-package :pin "1a2b3c4d5e")
|
||||
|
||||
|
||||
;; Doom's packages are pinned to a specific commit and updated from release to
|
||||
;; release. The `unpin!' macro allows you to unpin single packages...
|
||||
;; (unpin! pinned-package)
|
||||
;; ...or multiple packages
|
||||
;; (unpin! pinned-package another-pinned-package)
|
||||
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
|
||||
;; (unpin! t)
|
||||
@@ -0,0 +1,237 @@
|
||||
# Neovim Editor
|
||||
|
||||
My Neovim config based on [AstroNvim](https://github.com/AstroNvim/AstroNvim).
|
||||
For more details, visit the [AstroNvim website](https://astronvim.com/).
|
||||
|
||||
This document outlines neovim's configuration structure and various shortcuts/commands for efficient usage.
|
||||
|
||||
## Configuration Structure
|
||||
|
||||
| Description | Standard Location | My Location |
|
||||
| ------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------- |
|
||||
| Neovim's config | `~/.config/nvim` | AstroNvim's github repository, referenced as a flake input in this flake. |
|
||||
| AstroNvim's user configuration | `$XDG_CONFIG_HOME/astronvim/lua/user` | [./astronvim_user/](./astronvim_user/) |
|
||||
| Plugins installation directory (lazy.nvim) | `~/.local/share/nvim/` | The same as standard location, generated and managed by lazy.nvim. |
|
||||
| LSP servers, DAP servers, linters, and formatters | `~/.local/share/nvim/mason/`(by mason.nvim) | [./default.nix](./default.nix), installed by nix. |
|
||||
|
||||
## Update/Clean Plugins
|
||||
|
||||
Note that lazy.nvim will not automatically update plugins, so you need to update them manually.
|
||||
|
||||
```bash
|
||||
:Lazy update
|
||||
```
|
||||
|
||||
Remove all unused plugins:
|
||||
|
||||
```bash
|
||||
:Lazy clean
|
||||
```
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||

|
||||
|
||||
## Terminal Related
|
||||
|
||||
I used to use Neovim's terminal related shortcuts frequently, but now **I switched my daily terminal environment to zellij**,
|
||||
which provides a more powerful and stable terminal experience, so I don't use neovim's terminal feature anymore.
|
||||
|
||||
So here is zellij's terminal shortcuts I use frequently now:
|
||||
|
||||
| Action | Zellij's Shortcut |
|
||||
| ------------------------- | ------------------ |
|
||||
| Floating Terminal | `Ctrl + <p> + <w>` |
|
||||
| Horizontal Split Terminal | `Ctrl + <p> + <d>` |
|
||||
| Vertical Split Terminal | `Ctrl + <p> + <n>` |
|
||||
|
||||
## Visual Modes
|
||||
|
||||
| Action | Shortcut |
|
||||
| ------------------------ | ---------------------------------------- |
|
||||
| Toggle visual mode | `v` |
|
||||
| Toggle visual block mode | `<Ctrl> + v` (select a block vertically) |
|
||||
|
||||
## Incremental Selection
|
||||
|
||||
Provided by nvim-treesitter.
|
||||
|
||||
| Action | Shortcut |
|
||||
| ----------------- | -------------- |
|
||||
| init selection | `<Ctrl-space>` |
|
||||
| node incremental | `<Ctrl-space>` |
|
||||
| scope incremental | `<Alt-Space>` |
|
||||
| node decremental | `Backspace` |
|
||||
|
||||
## Search and Jump
|
||||
|
||||
Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligent search and jump plugin.
|
||||
|
||||
1. It enhaces the default search and jump behavior of neovim.(search with prefix `/`)
|
||||
|
||||
| Action | Shortcut |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------- |
|
||||
| Search | `/`(normal search), `s`(disable all code highlight, only highlight matches) |
|
||||
| Treesitter Search | `yR`,`dR`, `cR`, `vR`, `ctrl+v+R`(arround your matches, all the surrounding Treesitter nodes will be labeled) |
|
||||
| Remote Flash | `yr`, `dr`, `cr`, (arround your matches, all the surrounding Treesitter nodes will be labeled) |
|
||||
|
||||
## Text Manipulation
|
||||
|
||||
- Add at the end of multiple lines: `:normal A<text>`
|
||||
|
||||
- Execublock: `:A<text>`
|
||||
|
||||
- visual block mode(ctrl + v)
|
||||
- Append text at the end of each line in the selected block
|
||||
- If position exceeds line end, neovim adds spaces automatically
|
||||
|
||||
- Delete the last char of multivle lines: `:normal $x`
|
||||
|
||||
- Execute `$x` on each line
|
||||
- visual mode(v)
|
||||
- `$` moves cursor to the end of line
|
||||
- `x` deletes the character under the cursor
|
||||
|
||||
- Delete the last word of multiple lines: `:normal $bD`
|
||||
- Execute `$bD` on each line
|
||||
- visual mode(v)
|
||||
- `$` moves cursor to the end of line
|
||||
- `b` moves cursor to the beginning of the last word
|
||||
- `D` deletes from cursor to the end of line
|
||||
|
||||
## Commands & Shortcuts
|
||||
|
||||
| Action | Shortcut |
|
||||
| ----------------------------- | -------------- |
|
||||
| Learn Neovim's Basics | `:Tutor` |
|
||||
| Open file explorer | `<Space> + e` |
|
||||
| Focus Neotree to current file | `<Space> + o` |
|
||||
| Toggle line wrap | `<Space> + uw` |
|
||||
| Show line diagnostics | `gl` |
|
||||
| Show function/variable info | `K` |
|
||||
| Go to definition | `gd` |
|
||||
| References of a symbol | `gr` |
|
||||
|
||||
## Window Navigation
|
||||
|
||||
- Switch between windows: `<Ctrl> + h/j/k/l`
|
||||
- Resize windows: `<Ctrl> + Up/Down/Left/Right`
|
||||
- Note: On macOS, conflicts with system shortcuts
|
||||
- Disable in System Preferences -> Keyboard -> Shortcuts -> Mission Control
|
||||
|
||||
## Splitting and Buffers
|
||||
|
||||
| Action | Shortcut |
|
||||
| --------------------- | ------------- |
|
||||
| Horizontal Split | `\` |
|
||||
| Vertical Split | `\|` |
|
||||
| Next Buffer (Tab) | `]b` |
|
||||
| Previous Buffer (Tab) | `[b` |
|
||||
| Close Buffer | `<Space> + c` |
|
||||
|
||||
## Editing and Formatting
|
||||
|
||||
| Action | Shortcut |
|
||||
| ----------------------------------------------------- | -------------- |
|
||||
| Toggle buffer auto formatting | `<Space> + uf` |
|
||||
| Format Document | `<Space> + lf` |
|
||||
| Code Actions | `<Space> + la` |
|
||||
| Rename | `<Space> + lr` |
|
||||
| Opening LSP symbols | `<Space> + lS` |
|
||||
| Comment Line(support multiple lines) | `<Space> + /` |
|
||||
| Open filepath/URL at cursor(neovim's builtin command) | `gx` |
|
||||
| Find files by name (fzf) | `<Space> + ff` |
|
||||
| Grep string in files (ripgrep) | `<Space> + fw` |
|
||||
|
||||
## Sessions
|
||||
|
||||
| Action | Shortcut |
|
||||
| ------------------------------ | -------------- |
|
||||
| Save Session | `<Space> + Ss` |
|
||||
| Last Session | `<Space> + Sl` |
|
||||
| Delete Session | `<Space> + Sd` |
|
||||
| Search Session | `<Space> + Sf` |
|
||||
| Load Current Directory Session | `<Space> + S.` |
|
||||
|
||||
## Debugging
|
||||
|
||||
Press `<Space> + D` to view available bindings and options.
|
||||
|
||||
## Find and Replace
|
||||
|
||||
| Action | Command |
|
||||
| ------------------------ | ----------------------------------- |
|
||||
| Replace in selected area | `:s/old/new/g` |
|
||||
| Replace in current line | Same as above |
|
||||
| Replace in whole file | `:% s/old/new/g` |
|
||||
| Replace with regex | `:% s@\vhttp://(\w+)@https://\1@gc` |
|
||||
|
||||
1. `\v` means means that in the regex pattern after it can be used without backslash escaping(similar to python's raw string).
|
||||
2. `\1` means the first matched group in the pattern.
|
||||
|
||||
## Replace in the specific lines
|
||||
|
||||
| Action | Command |
|
||||
| ----------------------------------------- | -------------------------------------- |
|
||||
| From the 10th line to the end of the file | `:10,$ s/old/new/g` or `:10,$ s@^@#@g` |
|
||||
| From the 10th line to the 20th line | `:10,20 s/old/new/g` |
|
||||
|
||||
The postfix(flags) in the above commands:
|
||||
|
||||
1. `g` means replace all the matched strings in the current line/file.
|
||||
2. `c` means ask for confirmation before replacing.
|
||||
3. `i` means ignore case.
|
||||
|
||||
## Search and Replace Globally
|
||||
|
||||
| Description | Shortcut |
|
||||
| ------------------------------------------------------------ | ---------------------------------------------------------------- |
|
||||
| Open spectre.nvim search and replace panel | `<Space> + ss` |
|
||||
| Search and replace in command line(need install `sad` first) | `find -name "*.nix" \| sad '<pattern>' '<replacement>' \| delta` |
|
||||
|
||||
## Surrounding Characters
|
||||
|
||||
Provided by mini.surround plugin.
|
||||
|
||||
- Prefix `gz`
|
||||
|
||||
| Action | Shortcut | Description |
|
||||
| ------------------------------ | -------- | ----------------------------------------------- |
|
||||
| Add surrounding characters | `gzaiw'` | Add `'` around the word under cursor |
|
||||
| Delete surrounding characters | `gzd'` | Delete `'` around the word under cursor |
|
||||
| Replace surrounding characters | `gzr'"` | Replace `'` by `"` around the word under cursor |
|
||||
| Highlight surrounding | `gzh'` | Highlight `'` around the word under cursor |
|
||||
|
||||
## Text Manipulation
|
||||
|
||||
| Action | |
|
||||
| -------------------------------------- | ------------- |
|
||||
| Join Selection of Lines With Space | `:join` |
|
||||
| Join without spaces | `:join!` |
|
||||
| Join with LSP intelligence(treesj) | `<Space> + j` |
|
||||
| Split Line into Multiple Lines(treesj) | `<Space> + s` |
|
||||
|
||||
## Convert Text Case
|
||||
|
||||
| Action | |
|
||||
| -------------------- | --- |
|
||||
| Toggle text's case | `~` |
|
||||
| Convert to uppercase | `U` |
|
||||
| Convert to lowercase | `u` |
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
| Action | |
|
||||
| ---------------------------- | -------------------------------------------- |
|
||||
| Save selected text to a file | `:w filename` (Will show `:'<,'>w filename`) |
|
||||
| Show all Yank History | `:<Space> + yh` |
|
||||
| Show undo history | `:<Space> + uh` |
|
||||
|
||||
## Additional Resources
|
||||
|
||||
For more detailed information and advanced usage, refer to:
|
||||
|
||||
1. [AstroNvim walkthrough](https://astronvim.com/Basic%20Usage/walkthrough)
|
||||
2. [./astronvim_user/mapping.lua](./astronvim_user/mappings.lua)
|
||||
3. All the plugins' documentations
|
||||
@@ -0,0 +1,482 @@
|
||||
return {
|
||||
colorscheme = "catppuccin",
|
||||
|
||||
options = {
|
||||
opt = {
|
||||
relativenumber = true, -- Show relative numberline
|
||||
signcolumn = "auto", -- Show sign column when used only
|
||||
spell = false, -- Spell checking
|
||||
swapfile = false, -- Swapfile
|
||||
smartindent = false, -- fix https://github.com/ryan4yin/nix-config/issues/4
|
||||
title = true, -- Set the title of window to `filename [+=-] (path) - NVIM`
|
||||
-- The percentage of 'columns' to use for the title
|
||||
-- When the title is longer, only the end of the path name is shown.
|
||||
titlelen = 20,
|
||||
},
|
||||
},
|
||||
|
||||
plugins = {
|
||||
"AstroNvim/astrocommunity",
|
||||
-- colorscheme - catppuccin
|
||||
{ import = "astrocommunity.colorscheme.catppuccin" },
|
||||
-- Highly experimental plugin that completely replaces
|
||||
-- the UI for messages, cmdline and the popupmenu.
|
||||
-- { import = "astrocommunity.utility.noice-nvim" },
|
||||
-- Fully featured & enhanced replacement for copilot.vim
|
||||
-- <Tab> work with both auto completion in cmp and copilot
|
||||
{ import = "astrocommunity.media.vim-wakatime" },
|
||||
{ import = "astrocommunity.motion.leap-nvim" },
|
||||
{ import = "astrocommunity.motion.flit-nvim" },
|
||||
{ import = "astrocommunity.scrolling.nvim-scrollbar" },
|
||||
{ import = "astrocommunity.editing-support.todo-comments-nvim" },
|
||||
-- Language Support
|
||||
---- Frontend & NodeJS
|
||||
{ import = "astrocommunity.pack.typescript-all-in-one" },
|
||||
{ import = "astrocommunity.pack.tailwindcss" },
|
||||
{ import = "astrocommunity.pack.html-css" },
|
||||
{ import = "astrocommunity.pack.prisma" },
|
||||
{ import = "astrocommunity.pack.vue" },
|
||||
---- Configuration Language
|
||||
{ import = "astrocommunity.pack.markdown" },
|
||||
{ import = "astrocommunity.pack.json" },
|
||||
{ import = "astrocommunity.pack.yaml" },
|
||||
{ import = "astrocommunity.pack.toml" },
|
||||
---- Backend / System
|
||||
{ import = "astrocommunity.pack.lua" },
|
||||
{ import = "astrocommunity.pack.go" },
|
||||
{ import = "astrocommunity.pack.rust" },
|
||||
{ import = "astrocommunity.pack.python" },
|
||||
{ import = "astrocommunity.pack.java" },
|
||||
{ import = "astrocommunity.pack.cmake" },
|
||||
{ import = "astrocommunity.pack.cpp" },
|
||||
-- { import = "astrocommunity.pack.nix" }, -- manually add config for nix, comment this one.
|
||||
{ import = "astrocommunity.pack.proto" },
|
||||
---- Operation & Cloud Native
|
||||
{ import = "astrocommunity.pack.terraform" },
|
||||
{ import = "astrocommunity.pack.bash" },
|
||||
{ import = "astrocommunity.pack.docker" },
|
||||
{ import = "astrocommunity.pack.helm" },
|
||||
-- Motion
|
||||
{ import = "astrocommunity.motion.mini-surround" },
|
||||
-- https://github.com/echasnovski/mini.ai
|
||||
{ import = "astrocommunity.motion.mini-ai" },
|
||||
{ import = "astrocommunity.motion.flash-nvim" },
|
||||
-- diable toggleterm.nvim, zellij's terminal is far better than neovim's one
|
||||
{ "akinsho/toggleterm.nvim", enabled = false },
|
||||
{ "folke/flash.nvim", vscode = false },
|
||||
-- Lua implementation of CamelCaseMotion, with extra consideration of punctuation.
|
||||
{ import = "astrocommunity.motion.nvim-spider" },
|
||||
-- AI Assistant
|
||||
{ import = "astrocommunity.completion.copilot-lua-cmp" },
|
||||
-- Custom copilot-lua to enable filtypes: markdown
|
||||
{
|
||||
"zbirenbaum/copilot.lua",
|
||||
opts = function(_, opts)
|
||||
opts.filetypes = {
|
||||
yaml = true,
|
||||
markdown = true,
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"0x00-ketsu/autosave.nvim",
|
||||
-- lazy-loading on events
|
||||
event = { "InsertLeave", "TextChanged" },
|
||||
opts = function(_, opts)
|
||||
opts.prompt_style = "stdout" -- notify or stdout
|
||||
end,
|
||||
},
|
||||
|
||||
-- Provide a comparable s-expression editing experience in Neovim to that provided by Emacs.
|
||||
-- https://github.com/julienvincent/nvim-paredit
|
||||
{
|
||||
"julienvincent/nvim-paredit",
|
||||
config = function()
|
||||
require("nvim-paredit").setup()
|
||||
end,
|
||||
},
|
||||
|
||||
-- markdown preview
|
||||
{
|
||||
"0x00-ketsu/markdown-preview.nvim",
|
||||
ft = { "md", "markdown", "mkd", "mkdn", "mdwn", "mdown", "mdtxt", "mdtext", "rmd", "wiki" },
|
||||
config = function()
|
||||
require("markdown-preview").setup({
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the setup section below
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- clipboard manager
|
||||
{
|
||||
"gbprod/yanky.nvim",
|
||||
opts = function()
|
||||
local mapping = require("yanky.telescope.mapping")
|
||||
local mappings = mapping.get_defaults()
|
||||
mappings.i["<c-p>"] = nil
|
||||
return {
|
||||
highlight = { timer = 200 },
|
||||
picker = {
|
||||
telescope = {
|
||||
use_default_mappings = false,
|
||||
mappings = mappings,
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"y",
|
||||
"<Plug>(YankyYank)",
|
||||
mode = { "n", "x" },
|
||||
desc = "Yank text",
|
||||
},
|
||||
{
|
||||
"p",
|
||||
"<Plug>(YankyPutAfter)",
|
||||
mode = { "n", "x" },
|
||||
desc = "Put yanked text after cursor",
|
||||
},
|
||||
{
|
||||
"P",
|
||||
"<Plug>(YankyPutBefore)",
|
||||
mode = { "n", "x" },
|
||||
desc = "Put yanked text before cursor",
|
||||
},
|
||||
{
|
||||
"gp",
|
||||
"<Plug>(YankyGPutAfter)",
|
||||
mode = { "n", "x" },
|
||||
desc = "Put yanked text after selection",
|
||||
},
|
||||
{
|
||||
"gP",
|
||||
"<Plug>(YankyGPutBefore)",
|
||||
mode = { "n", "x" },
|
||||
desc = "Put yanked text before selection",
|
||||
},
|
||||
{ "[y", "<Plug>(YankyCycleForward)", desc = "Cycle forward through yank history" },
|
||||
{ "]y", "<Plug>(YankyCycleBackward)", desc = "Cycle backward through yank history" },
|
||||
{ "]p", "<Plug>(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" },
|
||||
{ "[p", "<Plug>(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" },
|
||||
{ "]P", "<Plug>(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" },
|
||||
{ "[P", "<Plug>(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" },
|
||||
{ ">p", "<Plug>(YankyPutIndentAfterShiftRight)", desc = "Put and indent right" },
|
||||
{ "<p", "<Plug>(YankyPutIndentAfterShiftLeft)", desc = "Put and indent left" },
|
||||
{ ">P", "<Plug>(YankyPutIndentBeforeShiftRight)", desc = "Put before and indent right" },
|
||||
{ "<P", "<Plug>(YankyPutIndentBeforeShiftLeft)", desc = "Put before and indent left" },
|
||||
{ "=p", "<Plug>(YankyPutAfterFilter)", desc = "Put after applying a filter" },
|
||||
{ "=P", "<Plug>(YankyPutBeforeFilter)", desc = "Put before applying a filter" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Enhanced matchparen.vim plugin for Neovim to highlight the outer pair.
|
||||
{
|
||||
"utilyre/sentiment.nvim",
|
||||
version = "*",
|
||||
event = "VeryLazy", -- keep for lazy loading
|
||||
opts = {
|
||||
-- config
|
||||
},
|
||||
init = function()
|
||||
-- `matchparen.vim` needs to be disabled manually in case of lazy loading
|
||||
vim.g.loaded_matchparen = 1
|
||||
end,
|
||||
},
|
||||
|
||||
-- joining blocks of code into oneline, or splitting one line into multiple lines.
|
||||
{
|
||||
"Wansmer/treesj",
|
||||
keys = { "<space>m", "<space>j", "<space>s" },
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
||||
config = function()
|
||||
require("treesj").setup({ --[[ your config ]]
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- File explorer(Custom configs)
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
opts = {
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
visible = true, -- visible by default
|
||||
hide_dotfiles = false,
|
||||
hide_gitignored = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
-- The plugin offers the alibity to refactor code.
|
||||
{
|
||||
"ThePrimeagen/refactoring.nvim",
|
||||
dependencies = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "nvim-treesitter/nvim-treesitter" },
|
||||
},
|
||||
},
|
||||
-- The plugin offers the abilibty to search and replace.
|
||||
{
|
||||
"nvim-pack/nvim-spectre",
|
||||
dependencies = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
},
|
||||
},
|
||||
|
||||
-- full signature help, docs and completion for the nvim lua API.
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
|
||||
{ "RRethy/vim-illuminate", config = function() end },
|
||||
|
||||
-- Language Parser for syntax highlighting / indentation / folding / Incremental selection
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
local utils = require("astronvim.utils")
|
||||
opts.incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<C-space>", -- Ctrl + Space
|
||||
node_incremental = "<C-space>",
|
||||
scope_incremental = "<A-space>", -- Alt + Space
|
||||
node_decremental = "<bs>", -- Backspace
|
||||
},
|
||||
}
|
||||
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, {
|
||||
-- neovim
|
||||
"vim",
|
||||
"lua",
|
||||
-- operation & cloud native
|
||||
"dockerfile",
|
||||
"hcl",
|
||||
"jsonnet",
|
||||
"regex",
|
||||
"terraform",
|
||||
"nix",
|
||||
"csv",
|
||||
-- other programming language
|
||||
"diff",
|
||||
"gitignore",
|
||||
"gitcommit",
|
||||
"latex",
|
||||
"sql",
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- implementation/definition preview
|
||||
{
|
||||
"rmagatti/goto-preview",
|
||||
config = function()
|
||||
require("goto-preview").setup({})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Undo tree
|
||||
{ "debugloop/telescope-undo.nvim" },
|
||||
|
||||
-- Install lsp, formmatter and others via home manager instead of Mason.nvim
|
||||
-- LSP installations
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
-- overwrite ensure_installed to install lsp via home manager(except emmet_ls)
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = {
|
||||
"emmet_ls", -- not exist in nixpkgs, so install it via mason
|
||||
}
|
||||
end,
|
||||
},
|
||||
-- Formatters/Linter installation
|
||||
{
|
||||
"jay-babu/mason-null-ls.nvim",
|
||||
-- ensure_installed nothing
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = nil
|
||||
opts.automatic_installation = false
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
opts = function(_, opts)
|
||||
local null_ls = require("null-ls")
|
||||
local code_actions = null_ls.builtins.code_actions
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
local formatting = null_ls.builtins.formatting
|
||||
local hover = null_ls.builtins.hover
|
||||
local completion = null_ls.builtins.completion
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md
|
||||
if type(opts.sources) == "table" then
|
||||
vim.list_extend(opts.sources, {
|
||||
-- Common Code Actions
|
||||
code_actions.gitsigns,
|
||||
-- common refactoring actions based off the Refactoring book by Martin Fowler
|
||||
code_actions.refactoring,
|
||||
code_actions.gomodifytags, -- Go - modify struct field tags
|
||||
code_actions.impl, -- Go - generate interface method stubs
|
||||
code_actions.shellcheck,
|
||||
code_actions.proselint, -- English prose linter
|
||||
code_actions.statix, -- Lints and suggestions for Nix.
|
||||
|
||||
-- Diagnostic
|
||||
diagnostics.actionlint, -- GitHub Actions workflow syntax checking
|
||||
diagnostics.buf, -- check text in current buffer
|
||||
diagnostics.checkmake, -- check Makefiles
|
||||
diagnostics.deadnix, -- Scan Nix files for dead code.
|
||||
|
||||
-- Formatting
|
||||
formatting.prettier, -- js/ts/vue/css/html/json/... formatter
|
||||
diagnostics.hadolint, -- Dockerfile linter
|
||||
formatting.black, -- Python formatter
|
||||
formatting.ruff, -- extremely fast Python linter
|
||||
formatting.goimports, -- Go formatter
|
||||
formatting.shfmt, -- Shell formatter
|
||||
formatting.rustfmt, -- Rust formatter
|
||||
formatting.taplo, -- TOML formatteautoindentr
|
||||
formatting.terraform_fmt, -- Terraform formatter
|
||||
formatting.stylua, -- Lua formatter
|
||||
formatting.alejandra, -- Nix formatter
|
||||
formatting.sqlfluff.with({ -- SQL formatter
|
||||
extra_args = { "--dialect", "postgres" }, -- change to your dialect
|
||||
}),
|
||||
formatting.nginx_beautifier, -- Nginx formatter
|
||||
null_ls.builtins.formatting.verible_verilog_format, -- Verilog formatter
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
-- Debugger installation
|
||||
{
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
-- overrides `require("mason-nvim-dap").setup(...)`
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = nil
|
||||
opts.automatic_installation = false
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "0.1.x",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
init = function()
|
||||
-- 1. Disable highlighting for certain filetypes
|
||||
-- 2. Ignore files larger than a certain filesize
|
||||
local previewers = require("telescope.previewers")
|
||||
|
||||
local _bad = { ".*%.csv", ".*%.min.js" } -- Put all filetypes that slow you down in this array
|
||||
local filesize_threshold = 300 * 1024 -- 300KB
|
||||
local bad_files = function(filepath)
|
||||
for _, v in ipairs(_bad) do
|
||||
if filepath:match(v) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local new_maker = function(filepath, bufnr, opts)
|
||||
opts = opts or {}
|
||||
if opts.use_ft_detect == nil then
|
||||
opts.use_ft_detect = true
|
||||
end
|
||||
|
||||
-- 1. Check if the file is in the bad_files array, and if so, don't highlight it
|
||||
opts.use_ft_detect = opts.use_ft_detect == false and false or bad_files(filepath)
|
||||
|
||||
-- 2. Check the file size, and ignore it if it's too big(preview nothing).
|
||||
filepath = vim.fn.expand(filepath)
|
||||
vim.loop.fs_stat(filepath, function(_, stat)
|
||||
if not stat then
|
||||
return
|
||||
end
|
||||
if stat.size > filesize_threshold then
|
||||
return
|
||||
else
|
||||
previewers.buffer_previewer_maker(filepath, bufnr, opts)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
buffer_previewer_maker = new_maker,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
-- Configure require("lazy").setup() options
|
||||
lazy = {
|
||||
defaults = { lazy = true },
|
||||
performance = {
|
||||
rtp = {
|
||||
-- customize default disabled vim plugins
|
||||
disabled_plugins = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
lsp = {
|
||||
config = {
|
||||
-- the offset_enconding of clangd will confilicts whit null-ls
|
||||
-- so we need to manually set it to utf-8
|
||||
clangd = {
|
||||
capabilities = {
|
||||
offsetEncoding = "utf-8",
|
||||
},
|
||||
},
|
||||
},
|
||||
-- enable servers that installed by home-manager instead of mason
|
||||
servers = {
|
||||
---- Frontend & NodeJS
|
||||
"tsserver", -- typescript/javascript language server
|
||||
"tailwindcss", -- tailwindcss language server
|
||||
"html", -- html language server
|
||||
"cssls", -- css language server
|
||||
"prismals", -- prisma language server
|
||||
"volar", -- vue language server
|
||||
---- Configuration Language
|
||||
"marksman", -- markdown ls
|
||||
"jsonls", -- json language server
|
||||
"yamlls", -- yaml language server
|
||||
"taplo", -- toml language server
|
||||
---- Backend
|
||||
"lua_ls", -- lua
|
||||
"gopls", -- go
|
||||
"rust_analyzer", -- rust
|
||||
"pyright", -- python
|
||||
"ruff_lsp", -- extremely fast Python linter and code transformation
|
||||
"jdtls", -- java
|
||||
"nil_ls", -- nix language server
|
||||
"bufls", -- protocol buffer language server
|
||||
"zls", -- zig language server
|
||||
---- HDL
|
||||
"verible", -- verilog language server
|
||||
---- Operation & Cloud Nativautoindente
|
||||
"bashls", -- bash
|
||||
"cmake", -- cmake language server
|
||||
"clangd", -- c/c++
|
||||
"dockerls", -- dockerfile
|
||||
"jsonnet_ls", -- jsonnet language server
|
||||
"terraformls", -- terraform hcl
|
||||
},
|
||||
formatting = {
|
||||
disabled = {},
|
||||
format_on_save = {
|
||||
enabled = true,
|
||||
allow_filetypes = {
|
||||
"go",
|
||||
"jsonnet",
|
||||
"rust",
|
||||
"terraform",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
-- Mapping data with "desc" stored directly by vim.keymap.set().
|
||||
--
|
||||
-- Please use this mappings table to set keyboard mapping since this is the
|
||||
-- lower level configuration and more robust one. (which-key will
|
||||
-- automatically pick-up stored data by this setting.)
|
||||
local utils = require "astronvim.utils"
|
||||
|
||||
require("telescope").load_extension("refactoring")
|
||||
require("telescope").load_extension("yank_history")
|
||||
require("telescope").load_extension("undo")
|
||||
|
||||
return {
|
||||
-- normal mode
|
||||
n = {
|
||||
-- second key is the lefthand side of the map
|
||||
-- mappings seen under group name "Buffer"
|
||||
["<leader>bn"] = { "<cmd>tabnew<cr>", desc = "New tab" },
|
||||
-- quick save
|
||||
["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
|
||||
|
||||
-- Terminal
|
||||
-- NOTE: https://neovim.io/doc/user/builtin.html#jobstart()
|
||||
-- 1. If {cmd} is a List it runs directly (no 'shell')
|
||||
-- 2. If {cmd} is a String it runs in the 'shell'
|
||||
-- search and replace globally
|
||||
['<leader>ss'] = {'<cmd>lua require("spectre").toggle()<CR>', desc = "Toggle Spectre" },
|
||||
['<leader>sw'] = {'<cmd>lua require("spectre").open_visual({select_word=true})<CR>', desc = "Search current word" },
|
||||
['<leader>sp'] ={'<cmd>lua require("spectre").open_file_search({select_word=true})<CR>', desc = "Search on current file" },
|
||||
|
||||
-- refactoring
|
||||
["<leader>ri"] = { function() require('refactoring').refactor('Inline Variable') end, desc = "Inverse of extract variable" },
|
||||
["<leader>rb"] = { function() require('refactoring').refactor('Extract Block') end, desc = "Extract Block" },
|
||||
["<leader>rbf"] = { function() require('refactoring').refactor('Extract Block To File') end, desc = "Extract Block To File" },
|
||||
["<leader>rr"] = { function() require('telescope').extensions.refactoring.refactors() end, desc = "Prompt for a refactor to apply" },
|
||||
["<leader>rp"] = { function() require('refactoring').debug.printf({below = false}) end, desc = "Insert print statement to mark the calling of a function" },
|
||||
["<leader>rv"] = { function() require('refactoring').debug.print_var() end, desc = "Insert print statement to print a variable" },
|
||||
["<leader>rc"] = { function() require('refactoring').debug.cleanup({}) end, desc = "Cleanup of all generated print statements" },
|
||||
|
||||
-- yank_history
|
||||
["<leader>yh"] = { function() require("telescope").extensions.yank_history.yank_history() end, desc = "Preview Yank History" },
|
||||
|
||||
-- undo history
|
||||
["<leader>uh"] = {"<cmd>Telescope undo<cr>", desc="Telescope undo" },
|
||||
|
||||
-- implementation/definition preview
|
||||
["gpd"] = { "<cmd>lua require('goto-preview').goto_preview_definition()<CR>", desc="goto_preview_definition" },
|
||||
["gpt"] = { "<cmd>lua require('goto-preview').goto_preview_type_definition()<CR>", desc="goto_preview_type_definition" },
|
||||
["gpi"] = { "<cmd>lua require('goto-preview').goto_preview_implementation()<CR>", desc="goto_preview_implementation" },
|
||||
["gP" ] = { "<cmd>lua require('goto-preview').close_all_win()<CR>", desc="close_all_win" },
|
||||
["gpr"] = { "<cmd>lua require('goto-preview').goto_preview_references()<CR>", desc="goto_preview_references" },
|
||||
},
|
||||
-- Visual mode
|
||||
v = {
|
||||
-- search and replace globally
|
||||
['<leader>sw'] = {'<esc><cmd>lua require("spectre").open_visual()<CR>', desc = "Search current word" },
|
||||
},
|
||||
-- visual mode(what's the difference between v and x???)
|
||||
x = {
|
||||
-- refactoring
|
||||
["<leader>ri"] = { function() require('refactoring').refactor('Inline Variable') end, desc = "Inverse of extract variable" },
|
||||
["<leader>re"] = { function() require('refactoring').refactor('Extract Function') end, desc = "Extracts the selected code to a separate function" },
|
||||
["<leader>rf"] = { function() require('refactoring').refactor('Extract Function To File') end, desc = "Extract Function To File" },
|
||||
["<leader>rv"] = { function() require('refactoring').refactor('Extract Variable') end, desc = "Extracts occurrences of a selected expression to its own variable" },
|
||||
["<leader>rr"] = { function() require('telescope').extensions.refactoring.refactors() end, desc = "Prompt for a refactor to apply" },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
pkgs,
|
||||
astronvim,
|
||||
...
|
||||
}:
|
||||
###############################################################################
|
||||
#
|
||||
# AstroNvim's configuration and all its dependencies(lsp, formatter, etc.)
|
||||
#
|
||||
#e#############################################################################
|
||||
let
|
||||
shellAliases = {
|
||||
v = "nvim";
|
||||
vdiff = "nvim -d";
|
||||
};
|
||||
in {
|
||||
xdg.configFile = {
|
||||
# astronvim's config
|
||||
"nvim" = {
|
||||
source = astronvim;
|
||||
force = true;
|
||||
};
|
||||
|
||||
# my custom astronvim config, astronvim will load it after base config
|
||||
# https://github.com/AstroNvim/AstroNvim/blob/v3.32.0/lua/astronvim/bootstrap.lua#L15-L16
|
||||
"astronvim/lua/user".source = ./astronvim_user;
|
||||
};
|
||||
|
||||
home.shellAliases = shellAliases;
|
||||
programs.nushell.shellAliases = shellAliases;
|
||||
|
||||
nixpkgs.config = {
|
||||
programs.npm.npmrc = ''
|
||||
prefix = ''${HOME}/.npm-global
|
||||
'';
|
||||
};
|
||||
|
||||
programs = {
|
||||
neovim = {
|
||||
enable = true;
|
||||
|
||||
defaultEditor = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
||||
# currently we use lazy.nvim as neovim's package manager, so comment this one.
|
||||
# Install packages that will compile locally or download FHS binaries via Nix!
|
||||
# and use lazy.nvim's `dir` option to specify the package directory in nix store.
|
||||
# so that these plugins can work on NixOS.
|
||||
#
|
||||
# related project:
|
||||
# https://github.com/b-src/lazy-nix-helper.nvim
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
# search all the plugins using https://search.nixos.org/packages
|
||||
telescope-fzf-native-nvim
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs;
|
||||
[
|
||||
#-- c/c++
|
||||
cmake
|
||||
cmake-language-server
|
||||
gnumake
|
||||
checkmake
|
||||
gcc # c/c++ compiler, required by nvim-treesitter!
|
||||
llvmPackages.clang-unwrapped # c/c++ tools with clang-tools such as clangd
|
||||
lldb
|
||||
|
||||
#-- python
|
||||
nodePackages.pyright # python language server
|
||||
python3Packages.black # python formatter
|
||||
python3Packages.ruff-lsp
|
||||
(python310.withPackages (
|
||||
ps:
|
||||
with ps; [
|
||||
pynvim # Python client and plugin host for Nvim
|
||||
|
||||
ipython
|
||||
pandas
|
||||
requests
|
||||
pyquery
|
||||
pyyaml
|
||||
]
|
||||
))
|
||||
|
||||
#-- rust
|
||||
rust-analyzer
|
||||
cargo # rust package manager
|
||||
rustfmt
|
||||
|
||||
#-- zig
|
||||
zls
|
||||
|
||||
#-- nix
|
||||
nil
|
||||
rnix-lsp
|
||||
# nixd
|
||||
statix # Lints and suggestions for the nix programming language
|
||||
deadnix # Find and remove unused code in .nix source files
|
||||
alejandra # Nix Code Formatter
|
||||
|
||||
#-- golang
|
||||
go
|
||||
gomodifytags
|
||||
iferr # generate error handling code for go
|
||||
impl # generate function implementation for go
|
||||
gotools # contains tools like: godoc, goimports, etc.
|
||||
gopls # go language server
|
||||
delve # go debugger
|
||||
|
||||
# -- java
|
||||
jdk17
|
||||
gradle
|
||||
maven
|
||||
spring-boot-cli
|
||||
|
||||
#-- lua
|
||||
stylua
|
||||
lua-language-server
|
||||
|
||||
#-- bash
|
||||
nodePackages.bash-language-server
|
||||
shellcheck
|
||||
shfmt
|
||||
|
||||
#-- javascript/typescript --#
|
||||
nodePackages.nodejs
|
||||
nodePackages.typescript
|
||||
nodePackages.typescript-language-server
|
||||
# HTML/CSS/JSON/ESLint language servers extracted from vscode
|
||||
nodePackages.vscode-langservers-extracted
|
||||
nodePackages."@tailwindcss/language-server"
|
||||
|
||||
#-- CloudNative
|
||||
nodePackages.dockerfile-language-server-nodejs
|
||||
# terraform # install via brew on macOS
|
||||
terraform-ls
|
||||
jsonnet
|
||||
jsonnet-language-server
|
||||
hadolint # Dockerfile linter
|
||||
|
||||
#-- Others
|
||||
taplo # TOML language server / formatter / validator
|
||||
nodePackages.yaml-language-server
|
||||
sqlfluff # SQL linter
|
||||
actionlint # GitHub Actions linter
|
||||
buf # protoc plugin for linting and formatting
|
||||
proselint # English prose linter
|
||||
racket-minimal # scheme language(racket cli only tools)
|
||||
|
||||
#-- Misc
|
||||
tree-sitter # common language parser/highlighter
|
||||
nodePackages.prettier # common code formatter
|
||||
marksman # language server for markdown
|
||||
glow # markdown previewer
|
||||
fzf
|
||||
|
||||
#-- Optional Requirements:
|
||||
gdu # disk usage analyzer, required by AstroNvim
|
||||
(ripgrep.override {withPCRE2 = true;}) # recursively searches directories for a regex pattern
|
||||
]
|
||||
++ (
|
||||
if pkgs.stdenv.isDarwin
|
||||
then []
|
||||
else [
|
||||
#-- verilog / systemverilog
|
||||
verible
|
||||
gdb
|
||||
]
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user