From fccc165720bc8cfd8decc852414595468c65be61 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 5 Nov 2021 18:39:36 +0100 Subject: Added neovim mappings and previous plugins --- config/nvim/init.lua | 18 ++--- config/nvim/lua/mappings.lua | 181 ++++++------------------------------------- config/nvim/lua/plugins.lua | 22 +++--- 3 files changed, 43 insertions(+), 178 deletions(-) (limited to 'config') diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 9113752..86e010e 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -1,9 +1,8 @@ require('plugins') -- common --- let mapleader = ' ' -- set leader key to space --- let maplocalleader = '-' -- set file local leader key to backslash --- vint: -ProhibitSetNoCompatible +vim.g.mapleader = ' ' -- set leader key to space +vim.g.maplocalleader = '-' -- set file local leader key to backslash vim.opt.compatible = false -- not compatible with vi vim.opt.number = true -- line number vim.opt.numberwidth = 1 -- line numbers gutter autowidth @@ -16,16 +15,15 @@ vim.opt.swapfile = false -- disable swap files vim.opt.scrolloff = 2 -- line padding when scrolling vim.opt.textwidth = 0 -- when line wrap occurs vim.opt.wrapmargin = 0 -- disable auto line wrapping +vim.opt.clipboard = 'unnamedplus' -- use system clipboard +vim.g.c_syntax_for_h = 1 -- .h file use C filetype instead of C++ vim.opt.encoding = "utf-8" -- utf-8 encoding --- vim.opt.scriptencoding = "utf-8" --- vim.opt.formatoptions -= 't' -- do not auto break line > 89 character -- filetype plugin indent on -- allow to add specific rules for certain type of file -- set mouse=a " mouse scrolling (heretic) vim.opt.shellredir = ">" -- don't inclue stderr when reading a command -- intuitif split opening vim.opt.splitbelow = true vim.opt.splitright = true --- vim.opt.fillchars = "vert:│" -- split separator -- tab vim.opt.expandtab = true -- tab to space @@ -46,10 +44,6 @@ vim.opt.laststatus=2 -- always a statusline (all window) vim.opt.showcmd = true -- show current partial command in the bottom right vim.opt.showmode = false -- dont show current mode (i.e --INSERT--) --- -- fold --- vim.opt.foldmethod=indent -- create fold based on the text indent --- vim.opt.nofoldenable -- not folded by default - -- colorscheme vim.opt.termguicolors = true vim.opt.background = "dark" @@ -64,6 +58,7 @@ vim.g.gruvbox_invert_selection = 0 require('lualine').setup { options = { theme = 'gruvbox', + icons_enabled = false, section_separators = '', component_separators = '' } @@ -87,9 +82,10 @@ require('nvim-treesitter.configs').setup { } } +require('nvim_comment').setup() + require('mappings') --- -- hi link juliaFunctionCall Identifier -- hi link juliaParDelim Delimiter -- diff --git a/config/nvim/lua/mappings.lua b/config/nvim/lua/mappings.lua index b609fbd..e37968a 100644 --- a/config/nvim/lua/mappings.lua +++ b/config/nvim/lua/mappings.lua @@ -1,122 +1,30 @@ local map = vim.api.nvim_set_keymap +map('', 'Y', 'y$', {}) -- 'Y' yank to the end of the line +map('i', 'kj', '', {}) -- kj to exit insert mode +map('', 'Q', '', {}) -- remove visual mode keybinding +map('n', 'sc', ':source $MYVIMRC', {}) -- source vimrc +map('n', ';', 'mqA;`q', {}) -- put semicolon at the end of line +map('n', 'cu', 'ct_', {}) -- common change until + -- split navigation -map('n', '', '', '', '', 's=', '=' {}) +map('n', '', '', {}) +map('n', '', '', {}) +map('n', '', '', {}) +map('n', '', '', {}) +map('n', 's=', '=', {}) + +-- search with very magic +map('n', ' /', '/\v', {}) +map('n', ' ?', '?\v', {}) --- common --- -- 'Y' yank to the end of the line --- noremap Y y$ --- -- kj to exit insert mode -map('i', 'kj', '', {}) --- -- remove visual mode keybinding --- noremap Q --- -- search with very magic --- nnoremap / /\v --- nnoremap ? ?\v --- -- move line up and down --- nnoremap _ ddkP --- nnoremap + ddp --- -- long move up/down --- nnoremap ( 10k --- nnoremap ) 10j --- -- tag nagigation --- nnoremap ] --- nnoremap t --- -- common change until --- nnoremap cu ct_ --- nnoremap cp ct) --- nnoremap c, ct, --- --- -- buffer navigation --- nnoremap bn :bn --- nnoremap bp :bp --- nnoremap :b# --- nnoremap bl :ls --- --- nnoremap sc :source $MYVIMRC -- source vimrc --- --- -- c --- -- create c function body from prototype --- nnoremap gcf A{}j --- --- -- initialise a school header file --- function PutHeaderBoilerPlate() --- let l:filename = join(split(toupper(expand('%:t')), '\.'), '_') --- -- echom l:filename --- call append(12, '#ifndef ' . l:filename) --- call append(13, '# define ' . l:filename) --- call append(15, '#endif') --- endfunction --- nnoremap gch :Stdheader:call PutHeaderBoilerPlate() --- --- -- put semicolon at the end of line --- nnoremap ; mqA;`q --- --- -- cpp --- -- Put Coplien Form boilerplate class --- function PutCoplienFormFunc(name) --- let l:default_constructor = a:name . '();\n' --- let l:copy_constructor = a:name . '(const ' . a:name . '& other);\n' --- let l:copy_operator = a:name . '& operator=(const ' . a:name . '& other);\n' --- let l:destructor = '~' . a:name . '();\n' --- --- execute 'normal iclass ' . a:name . '\n{\npublic:\n' . l:default_constructor . l:copy_constructor . l:copy_operator . l:destructor . '\nprivate:\n};\n' --- execute 'normal <2{' --- endfunction --- -- Put Coplien Form boilerplate according to filename --- command! PutCoplienFormFile call PutCoplienFormFunc(split(expand('%:t'), '\.')[0]) --- command! -nargs=1 PutCoplienForm call PutCoplienFormFunc(--") --- --- -- quickfix window toggle --- nnoremap q :call QuickfixToggle() --- nnoremap n :cnext --- nnoremap p :cprevious --- let g:quickfix_is_open = 0 --- function! QuickfixToggle() --- if g:quickfix_is_open --- cclose --- let g:quickfix_is_open = 0 --- else --- copen --- let g:quickfix_is_open = 1 --- endif --- endfunction --- --- function! CountScopeLines() --- normal! mq --- execute '/^}' --- let l:end_brace = line('.') --- execute '?^{' --- let l:start_brace = line('.') --- normal! k --- let l:scope_len = l:end_brace - l:start_brace - 1 --- let l:scope_name = substitute(getline('.'), '\t', ' ', 'g') --- echom l:scope_len . ' lines in |' . l:scope_name . '|' --- normal! `q --- endfunction --- command! CountScopeLines call CountScopeLines() --- --- -- make --- nnoremap m :make all --- --- augroup vimrc --- autocmd! --- augroup END --- -- -- hook -- -- remove trailing white space on save -- autocmd vimrc BufWritePre * %s/\s\+$//e -- -- dirty hack to disable this feature on markdown (autocmd! wouldn't work) -- autocmd vimrc BufReadPre *.md autocmd! BufWritePre --- --- -- filetype --- -- real tab in c file for school projects --- let g:c_syntax_for_h = 1 -- filetype=c in header files instead of filetype=cpp --- + + -- augroup vimrc_files -- autocmd! -- -- school c @@ -128,54 +36,13 @@ map('i', 'kj', '', {}) -- autocmd FileType haskell set formatprg=stylish-haskell -- autocmd FileType lisp,html,css,htmldjango setlocal shiftwidth=2 -- augroup END + +-- pluggins -- --- --""""""""""" --- -- pluggins " --- --""""""""""" --- --- -- directory to ignore when searching in file tree --- vim.opt.wildignore=*/doc/*,*/tmp/*,*.o,*.so,*.a,*.swp,*.zip,*/node_modules/*,*/vendor/*,.bundle/*,bin/*,.git/*,*.pyc --- --- -- ctrlp --- -- ctrlp ignore all stuff in the .gitignore --- -- let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] --- -- let g:ctrlp_working_path_mode = 'rw' --- -- let g:ctrlp_mruf_case_sensitive = 0 --- -- --- -- nnoremap p :CtrlPTag --- --- -- fzf.vim --- nnoremap :GFiles --exclude-standard --others --cached --- nnoremap p :Tags --- --- -- quick-scope --- -- let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] --- --- -- man-plugin --- -- runtime! ftplugin/man.vim --- -- let g:ft_man_open_mode = 'vert' " open in a vertical split --- -- let g:ft_man_no_sect_fallback = 2 " if page specified fallback to page 2 (syscall pages) --- -- autocmd Filetype man unmap q: hmmmm?? --- --- -- eazy-align --- xmap ga (EasyAlign) --- nmap ga (EasyAlign) --- --- vnoremap c y:call system(--xclip -selection clipboard", getreg("\"")) --- nnoremap v :call setreg(--\"", system("xclip -selection clipboard -o"))p --- --- let g:c_formatter_42_format_on_save = 0 --- --- let g:gutentags_ctags_exclude = ['doc/*', 'docs/*', 'Makefile', '.mypy_cache', '.pytest_cache', '.tox', 'build/*', 'dist/*'] --- -- let g:gutentags_ctags_exclude_wildignore = 1 --- --- let g:goyo_height = 90 --- let g:goyo_width = 100 --- --- vim.opt.viminfo+=n$XDG_CACHE_HOME/vim/viminfo --- --- let g:python_highlight_all = 1 --- +-- eazy-align +map('x', 'ga', ':EasyAlign', {}) +map('n', 'ga', ':EasyAlign', {}) + -- nnoremap l :SidewaysRight -- nnoremap h :SidewaysLeft -- nnoremap w :ArgWrap diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua index 7bdb86f..a37dd64 100644 --- a/config/nvim/lua/plugins.lua +++ b/config/nvim/lua/plugins.lua @@ -1,25 +1,27 @@ vim.cmd [[packadd packer.nvim]] return require('packer').startup(function() - use 'wbthomason/packer.nvim' - - use {"ellisonleao/gruvbox.nvim", requires = {"rktjmp/lush.nvim"}} - + use 'wbthomason/packer.nvim' -- plugin manager (can manage itself) + use 'terrortylor/nvim-comment' -- comments + use 'junegunn/vim-easy-align' -- align + use 'AndrewRadev/sideways.vim' -- Move arguments sideways + use 'FooSoft/vim-argwrap' -- Put arguments on multiple lines + use 'tpope/vim-eunuch' -- basic commands on current file (Rename/Remove) + -- color scheme + use {'ellisonleao/gruvbox.nvim', requires = {'rktjmp/lush.nvim'}} + -- status line use { 'nvim-lualine/lualine.nvim', requires = {'kyazdani42/nvim-web-devicons', opt = true} } - + -- better syntax highlight for everything use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - + -- fuzzy finder (replace fzf.vim or ctrlp.vim) use { 'nvim-telescope/telescope.nvim', - requires = { {'nvim-lua/plenary.nvim'} } + requires = {'nvim-lua/plenary.nvim'} } - - use 'terrortylor/nvim-comment' - require('nvim_comment').setup() end) -- cgit