42 norminette (linter) for vim. It shows norm errors directly in vim, no more switching between vim and norminette.
Supports both Norm version 2 and Norm version 3.
norminette-vim needs syntastic and the norminette to work.
You will need a plugin manager to install syntastic and norminette-vim. I recommend vim-plug.
- If you are not on a 42 mac, install the norminette.
- Install syntastic and norminette-vim with your plugin manager. See exemple below.
With vim-plug, add this to the beginning of your ~/.vimrc
(or ~/.config/nvim/init.vim
for neovim):
call plug#begin()
Plug 'vim-syntastic/syntastic'
Plug 'alexandregv/norminette-vim'
call plug#end()
then restart vim and run :PlugInstall
- Copy the configuration to your
~/.vimrc
(or~/.config/nvim/init.vim
for neovim). Note that first line is mandatory.
Here is the configuration I recommend. You at least need the first line to enable the checker.
" Enable norminette-vim (and gcc)
let g:syntastic_c_checkers = ['norminette', 'gcc']
let g:syntastic_aggregate_errors = 1
" Set the path to norminette (do no set if using norminette of 42 mac)
let g:syntastic_c_norminette_exec = 'norminette'
" Support headers (.h)
let g:c_syntax_for_h = 1
let g:syntastic_c_include_dirs = ['include', '../include', '../../include', 'libft', '../libft/include', '../../libft/include']
" Pass custom arguments to norminette (this one ignores 42header)
let g:syntastic_c_norminette_args = '-R CheckTopCommentHeader'
" Check errors when opening a file (disable to speed up startup time)
let g:syntastic_check_on_open = 1
" Enable error list
let g:syntastic_always_populate_loc_list = 1
" Automatically open error list
let g:syntastic_auto_loc_list = 1
" Skip check when closing
let g:syntastic_check_on_wq = 0
To select the Norm version (2 or 3), just set g:syntastic_c_norminette_exec
to the right norminette path.
- For v2 (42Paris/norminette), it is probably
~/.norminette/norminette.rb
. - For v3 (42School/norminette),
norminette
should be enough if you installed it correctly.
Make sure that thenorminette
executable is available in your PATH. Check it withwhereis norminette
andtype -a norminette
.
If not found, make sure that Python's bin directory is in your PATH. Get it withpython3 -m site
orpython -m site
.
Open any .c
file and you should see your norm errors (if any!).
You can open the error list with :Errors
Vim has a native feature (vim-compiler and quickfix) which gives almost the same result. It basically just lacks the (sweet) line indicators on the left side.
git clone https://github.com/alexandregv/norminette-vim ~/.vim/pack/syntax/start/norminette-vim
- Open a
.c
file and run:Norminette
If needed, you can specify norminette path by adding let g:norminette_exec = '~/.norminette/norminette.rb'
to your ~/.vimrc
(or ~/.config/nvim/init.vim
for neovim).
- norminette-action - GitHub Action (CI) to test norminette after each push, automatically.
- norminette-action-demo - Demo repository for norminette-action.
- norminette-docker - A docker image for norminette. Used by norminette-action.
All of these are compatible with Norm version 2 and 3.