From 7edb0f0e99783f846c03c45b344de36540edf193 Mon Sep 17 00:00:00 2001 From: Hizenberg469 Date: Wed, 27 Aug 2025 20:05:39 +0300 Subject: [PATCH] Some changes in env_setup.sh and Plugin configuration in .vimrc --- .vimrc | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++-- env_setup.sh | 30 +++++++++++------ 2 files changed, 110 insertions(+), 11 deletions(-) diff --git a/.vimrc b/.vimrc index 66d29df..68a8f88 100644 --- a/.vimrc +++ b/.vimrc @@ -143,7 +143,7 @@ endif call plug#begin() Plug 'dense-analysis/ale' " linting and fixing code. - Plug 'airblade/vim-gitgutter' " a git diff in the sign colomn. + "Plug 'airblade/vim-gitgutter' " a git diff in the sign colomn. Plug 'habamax/vim-asciidoctor' " Feature-full environment for ASCII Docs. Plug 'majutsushi/tagbar' " Utility to easily browse the tag. Plug 'mbbill/undotree' " Utility to view undo history @@ -158,11 +158,98 @@ call plug#begin() Plug 'vim-scripts/c.vim' " A packages of tools for C and C++. Plug 'vimwiki/vimwiki' " A personal wiki plugin for Vim. Plug 'voldikss/vim-floaterm' " A plugin for floating terminal inside vim. - + Plug 'tpope/vim-commentary' " Commenting tool + Plug 'vim-airline/vim-airline-themes' " Themes for airline + Plug 'vim-scripts/DoxygenToolkit.vim' " Doxygen support + Plug 'vim-scripts/SpellCheck' " Spell checking call plug#end() " Plugin enable option + +" For dense-analysis/ale - linting +" Ignore git commit when linting (highly annoying) +let g:ale_pattern_options = { + \ 'COMMIT_EDITMSG$': {'ale_linters': [], 'ale_fixers': []} + \ } +let g:ale_linters = { + \ 'yaml': ['yamllint'], + \ 'cpp': ['clangtidy'], + \ 'c': ['clangtidy'], + \ 'asciidoc': ['cspell'], + \ 'markdown': ['cspell'] + \ } +let g:ale_fixers = { + \ 'cpp': ['clang-format'], + \ 'c': ['clang-format']} + +" Automatic fixing +autocmd FileType c nnoremap f (ale_fix) + +" General settings +let g:ale_linters_explicit = 1 +let g:ale_completion_enabled = 1 +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' +let g:ale_set_balloons=1 +let g:ale_hover_to_floating_preview=1 +let g:ale_use_global_executables = 1 +let g:ale_sign_column_always = 1 +let g:ale_disable_lsp = 1 + +" C++ linting +let g:ale_cpp_clangtidy_options = '-checks=-*,cppcoreguidelines-*' +let g:ale_cpp_clangtidy_checks = ['readability-*,performance-*,bugprone-*,misc-*'] +let g:ale_cpp_clangtidy_checks += ['clang-analyzer-cplusplus-doc-comments'] + +" C linting +let g:ale_c_clangtidy_options = '-checks=-*,cppcoreguidelines-*' +let g:ale_c_clangtidy_checks = ['readability-*,performance-*,bugprone-*,misc-*'] +let g:ale_c_clangtidy_checks += ['-readability-function-cognitive-complexity'] +let g:ale_c_clangtidy_checks += ['-readability-identifier-length'] +let g:ale_c_clangtidy_checks += ['-misc-redundant-expression'] +let g:ale_c_build_dir_names = ['build', 'release', 'debug'] + +" This function searches for the first clang-tidy config in parent directories and sets it +function! SetClangTidyConfig() + let l:config_file = findfile('.clang-tidy', expand('%:p:h').';') + if !empty(l:config_file) + let g:ale_c_clangtidy_options = '--config=' . l:config_file + let g:ale_cpp_clangtidy_options = '--config=' . l:config_file + endif +endfunction + +" Run this for c and c++ files +autocmd BufRead,BufNewFile *.c,*.cpp,*.h,*.hpp call SetClangTidyConfig() + + + +" For tpope/vim-fugitive - git integration. + +nnoremap gg :Git +nnoremap gs :Git status +nnoremap gc :Git commit +nnoremap gb :Git blame +nnoremap gd :Git difftool +nnoremap gm :Git mergetool +nnoremap gdv :Gvdiffsplit +nnoremap gdh :Gdiffsplit + + +" For airblade/vim-gitgutter - git status reporting line by line + + +" For preservim/nerdtree: the battle tested file explorer +let g:NERDTreeWinSize = 40 +nnoremap :NERDTreeToggle +let NERDTreeIgnore = ['\.o$', '\.obj$', '\.a$', '\.so$', '\.out$', '\.git$'] +let NERDTreeShowHidden = 1 + + +" For majutsushi/tagbar: the ultimate tag bar +nmap :TagbarToggle + + + " For rainbow coloring of Parentheses let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle diff --git a/env_setup.sh b/env_setup.sh index c100ce3..c97d28a 100644 --- a/env_setup.sh +++ b/env_setup.sh @@ -8,6 +8,15 @@ for development in C and C++. cmt +user = "" + +if [ '$(whoami)' = 'root' ]; then + user = "" +else + user = "sudo" +fi + + # To setup the environment function settingUpVimrc{ @@ -34,14 +43,6 @@ function settingUpLatestVim{ # Installing the required packages. - user = "" - - if [ '$(whoami)' = 'root' ]; then - - user = "" - else - - user = "sudo" $user apt install git $user apt install make @@ -55,5 +56,16 @@ function settingUpLatestVim{ git clone https://github.com/vim/vim.git # Configure for compilation. - ./vim/src/configure --with-features=huge --enable-python3interp=yes --enable-multibyte --enable-cscope --prefix=/usr/local + + DIR = /usr/local # Directory to setup the latest vim build. + + if [ $# -gt 0 ]; then + DIR = $1 + fi + + ./vim/src/configure --with-features=huge --enable-python3interp=yes --enable-multibyte --enable-cscope --prefix=$DIR } + + +# For ctags +# $user apt install universal-ctags -y