Skip to content

wgurecky/nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

202 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

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.

Depends

Neovim plugins are not listed here. lazy.nvim handles installation and updates of all neovim plugins.

Optional

Install

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

Config

C++ / C

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

Build

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.

Auto Completion

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.

Python

Optional: Place flake8 file in ~/.config/. to ignore some minor PEP8 violation warnings from showing up in the quickfix window.

Auto Completion

Auto complete for python requires the ty language server to be installed:

pip install ty

Linting

Install ruff, for ex:

pip install ruff

Breakpoints in Python

In normal mode <leader> b inserts a breakpoint on the line above the current cursor position.

Notes

Telescope Find File

To search for a file in the current project:

<C-p>

Find/Replace Mappings and Shortcuts

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

Code folding

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.

About

Neovim config files for c,c++, and python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published