Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jbuckmccready/neovim_config
Basic neovim config
https://github.com/jbuckmccready/neovim_config
Last synced: 2 months ago
JSON representation
Basic neovim config
- Host: GitHub
- URL: https://github.com/jbuckmccready/neovim_config
- Owner: jbuckmccready
- Created: 2024-07-16T06:49:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-14T18:48:26.000Z (4 months ago)
- Last Synced: 2024-08-15T05:42:09.753Z (4 months ago)
- Language: Lua
- Size: 144 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Hacked Neovim Setup
This is experimental/learning base setup for `neovim` with the goal of creating a starting point that seems "sensible" to me for code editing (specifically Rust to start).
Some goals:
- Cover all the basics: fast navigation, code completion/navigation, syntax highlighting, decent color scheme with semantic highlighting, etc.
- Don't compromise on any behavior I like about `vscode`, for example autocompletion behavior has been configured to match `vscode` default
- Avoid bloat/complexity/redundant configuration### Contents
This git repository contains both `neovim` and `alacritty` configuration files in the `nvim` and `alacritty` directories respectively. E.g., on MacOS the path will be `~/.config/nvim` and `~/.config/alacritty`, on Windows it will be `~/AppData/Local/nvim` and `~/AppData/Roaming/alacritty` (or maybe different if installed differently).
Note also included is an optional color scheme for `alacritty` as toml file imported into `alacritty.toml`. File path must be changed if path to config is not `~/.config.alacritty`. Check the `alacritty.toml` file for more settings that were tweaked (e.g., to open maximized without window border).
`alacritty` was added just for convenience of getting a terminal running that will work.
### Things covered
- rust/go/lua via `mason`/`mason-lsp-config` and `rustaceanvim` (thin wrapper on lsp) for lsp, `treesitter` for syntax highlighting, and `cmp` for auto-completions
- git via `neogit` (main git/diff operations) and `gitsigns` (indicators and blame line in editor)
- navigation via `telescope` (including on lsp symbols/info), `neotree`, `outline`, `hop`, and `mini.bracketed`
- status line via `lualine`
- general ui improvements with `dressing` (e.g., for code actions)### External tools notes
- you will need `alacritty` or some other decent terminal for real colors if on MacOS (default terminal is too limited), I switched to `alacritty` for speed
- nerd font for icons can be downloaded from [here](https://www.nerdfonts.com/font-downloads) (I am currently using ZedMono), then set it in terminal settings (if using `alacritty` see the `alacritty/alacritty.toml` file for example but this is in iTerm2 UI profile settings if using iTerm2 for example)
- color scheme is set to `catppuccin-mocha`, so far my favorite dark theme, I added some other popular color schemes as well
- `:TSInstall rust` for best syntactic highlighting and rust analyzer for rust lsp (`rustup component add rust-analyzer` OR can probably also install via `mason` plugin as well `:LspInstall rust_analyzer`)
- `:LspInstall gopls` for go lsp (using `mason`), `TSInstall go` for go treesitter (used for syntax highlighting)
- `:LspInstall lua_ls` for lua lsp (using `mason`), `TSInstall lua` not required currently since it's in `ensure_installed` in `treesitter.lua`
- `:LspInstall zls` for zig lsp, `TSInstall zig` for zig treesitter (used for syntax highlighting)
- `cmake` and c compiler for building `telescope-fzf-native.nvim` (greatly speeds up searching in `neotree` and `telescope`)
- `git` for git things
- `fd` for faster file browsing
- `ripgrep` for telescope live grep### Key mappings
I tried to keep all custom key mappings that are not associated with a plugin mode (anything that works in a standard mode inside a buffer) inside the `nvim/lua/config/keymappings.lua` file. There are other key mappings that are specific to plugin modes, e.g., telescope or autocompletion that are assigned during setup of the plugin. Additionally there are some key mappings added by `mini.basic` that can be found looking at `:h mini.basic`.
### Workflow
NOTE: `Space` is set as `` key, so wherever `` is shown it is `Space` unless you change the leader key (in `lua/config/lazy.lua`). `mini.clue` plugin is used to help discover key mappings (a popup is shown in UI after first key map is pressed to show following key maps available).
I try to use default key mappings as much as possible (when they are sensible) and anything not mentioned here is likely utilizing default key mappings, I use ``, ``, `` can be used to jump between windows, `\` followed by `s` to toggle spelling, `b` toggle background, `h` toggle highlight, etc.
Use `neotree` (`t`) to toggle open file tree browser, `?` for help, fast search via `/` or `#` inside of it, can be used to change the neovim working directory (`.`) for telescope file finding.
Use `telescope` (`f` to access group with commands) to do file search (e.g, `ff`, equivalent to `p` in `vscode`), buffer search, live grep search using `ripgrep`, and more. One very useful telescope search is to search help/documentation, telescope is also used for LSP navigation/browser, e.g., `fr` for find all references for symbol under cursor, `fd` for all lsp diagnostics (warnings/errors), etc.
Use `hop` (remapped `f`, `F`, `t`, `T` for single char jump and `s` for more hop commands) for easier buffer navigation.
Use tabs with tuned key mappings: `n` for new tab, `q` close tab, `{number}` to jump to tab number, `h` to cycle left one tab, `l` to cycle right one tab.
Use jump out of terminal mode via usual `h`, `j`, `k`, `h` without having to return to normal mode first (makes having split buffer for terminal more convenient).
Use `neogit` and `Gitsigns` for git operations and viewing diffs (`g` to open command group, `gg` will open main summary/status, `gd` will diff current file unstaged changes, and more). From main `neogit` status (`gg`) you can commit, pull, push, etc., use `?` to get full keymappings. Additionally you can use `telescope` to interact with git status, commits, and stash.
Use `outline` (`o`) for code/symbols outline (similar to `neotree` but for symbols in file).
Some additional notes:
- Cycle auto-completions via `C-n` (or ``) and `C-p` (or ``), `tab` or `` to complete.
- Editing actions (symbol rename, lsp code action, spell suggest, etc.): `e`
- Toggle `spell` with `\s` to turn on/off spell check, `es` with cursor over word for spell suggest
- Hover (for peeking docs on symbol): `K` (press again to toggle into it to jump to symbols from `rust-analyzer`)
- `` to open Rust docs link for symbol under cursor
- `:RustLsp expandMacro` to recursively expand Rust macro under cursor (no key mapping since it's not frequent)