Wgurecky's neovim configuration files. Useful for rust, cpp, python, and latex files.
This config depends on neovim's new lsp (language server protocol) integration.
Work in progress:
- Migrating to pure lua configuration.
- neovim with built in lsp (neovim >=v0.5) formerly nvim-lsp
- rust-analyzer
- ty
- ruff
- pynvim
- clang
- clangd
Neovim plugins are not listed here. lazy.nvim handles installation and updates of all neovim plugins.
Clone this repo into your ~/.config dir:
cd ~/.config && git clone https://github.com/wgurecky/nvim
On neovim startup lazy.nvim should try to download automatically, if not install from https://github.com/folke/lazy.nvim
Next, run :Lazy sync to install all plugins followed by :Lazy show
This neovim configuration assumes that a C/C++ project is built out of the src tree and is a git repository:
PROJECT_BASE
+-- CMakeLists.txt
+-- README.md
+-- .git
| +-- FETCH_HEAD
| +-- '...'
+-- build
| +-- do_configure.sh
| +-- makefile
+-- src
| +-- foo_bar.cpp
| +-- foo_bar.hpp
A function present in the included init.vim attempts to set makeprg automatically. The function might not always produce the expected result. Check that makeprg is set by issuing:
:set makeprg
To manually set makeprg:
:set makeprg=make\ -C\ ~/path/to/project/build
Once makeprg is verified, run:
:Make!
Which will launch make in the background so that you can continue to edit uninterrupted. To view the results run:
:Copen
Note: The designated project build folder name can be adjusted in the ./ftplugin/<c,cpp> files. By default it is set to build.
Clangd provides autocompletion for C/C++ projects. Some linux distributions have a clang-tools package that contains Clangd.
To use Clangd you must first generate a compilation database with the cmake option:
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on \
If cmake is not the build system of choice one can use the tool Bear to generate a json compilation database instead.
Optional:
Place flake8 file in ~/.config/. to ignore some minor PEP8 violation warnings from showing up in the quickfix window.
Auto complete for python requires the ty language server to be installed:
pip install ty
Install ruff, for ex:
pip install ruff
In normal mode <leader> b inserts a breakpoint on the line above the current cursor position.
To search for a file in the current project:
<C-p>
To search and replace a word inside all files in a directory:
:Ack {pattern} [{dir}]
:cdo s/foo/bar/gc | update
To search and replace all instances of a word inside a project that is a git repository use:
:vg <pattern>
:cdo s/foo/bar/gc | update
or
<C-f> <pattern>
<C-q>
:cdo s/foo/bar/gc | update
To search and replace all instances of the current word under the cursor in the current git repo do:
<leader>*
<C-q>
:cdo s/foo/bar/gc | update
Where <leader> is set to \ by default. The <C-q> (Ctrl+q) is required to send the telescope results to the quickfix list.
To find replace the current word under the cursor in the current file use:
<leader>s
The ./ftplugin directory provides code folding settings.
By default, folding by indentation level is on. za toggles folding for the current indent level. zR and zM unfolds and folds all respectively.