Skip to content

alexandregv/norminette-vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

norminette-vim

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.

Screenshot

Installation

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.

  1. If you are not on a 42 mac, install the norminette.
  2. 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

  1. Copy the configuration to your ~/.vimrc (or ~/.config/nvim/init.vim for neovim). Note that first line is mandatory.

Configuration

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

Norm version

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 the norminette executable is available in your PATH. Check it with whereis norminette and type -a norminette.
    If not found, make sure that Python's bin directory is in your PATH. Get it with python3 -m site or python -m site.

Usage

Open any .c file and you should see your norm errors (if any!).
You can open the error list with :Errors

Don't want to bother with this syntastic/plugins stuff? Check this

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.

  1. git clone https://github.com/alexandregv/norminette-vim ~/.vim/pack/syntax/start/norminette-vim
  2. 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).

See also

All of these are compatible with Norm version 2 and 3.

Stargazers over time

Stargazers over time

About

42 norminette (linter) for vim

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published