From e50fe9a2548d9742e006081f8ebc35bd36cd2dd6 Mon Sep 17 00:00:00 2001 From: surenyi Date: Fri, 11 Nov 2022 23:16:54 +0800 Subject: [PATCH] add neoformat Signed-off-by: surenyi --- linter/.clang-format | 2 +- vim9/vimrc | 116 ++++++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 51 deletions(-) diff --git a/linter/.clang-format b/linter/.clang-format index 038e06d..1f61625 100644 --- a/linter/.clang-format +++ b/linter/.clang-format @@ -123,5 +123,5 @@ SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp03 TabWidth: 4 -UseTab: AlignWithSpaces +UseTab: Never ... diff --git a/vim9/vimrc b/vim9/vimrc index 21976e3..2d0107c 100644 --- a/vim9/vimrc +++ b/vim9/vimrc @@ -106,6 +106,7 @@ Plug 'kana/vim-textobj-line' Plug 'wellle/targets.vim' Plug 'fatih/vim-go' +Plug 'sbdchd/neoformat' Plug 'jlanzarotta/bufexplorer' Plug 'joshdick/onedark.vim' @@ -131,7 +132,6 @@ Plug 'mbbill/undotree' Plug 'voldikss/vim-floaterm' Plug 'voldikss/LeaderF-floaterm' Plug 'skywind3000/asyncrun.vim' -Plug 'ptzz/lf.vim' Plug 'lervag/vimtex' @@ -190,7 +190,6 @@ Plug 'machakann/vim-highlightedyank' call plug#end() let g:deoplete#enable_at_startup = 1 -let g:lf_map_keys = 0 "}}} "{{{ mapleader=SPACE @@ -204,9 +203,9 @@ nnoremap :WhichKey ',' "{{{ colorscheme " Important!! if has('termguicolors') - let &t_8f = "\[38;2;%lu;%lu;%lum" - let &t_8b = "\[48;2;%lu;%lu;%lum" - set termguicolors + let &t_8f = "\[38;2;%lu;%lu;%lum" + let &t_8b = "\[48;2;%lu;%lu;%lum" + set termguicolors endif set background=dark @@ -266,43 +265,43 @@ let g:airline_theme='nord' "{{{ vim-lsp function! s:on_lsp_buffer_enabled() abort - setlocal omnifunc=lsp#complete - setlocal signcolumn=yes - if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif - nmap gd (lsp-definition) - nmap gs (lsp-document-symbol-search) - nmap gS (lsp-workspace-symbol-search) - nmap gr (lsp-references) - nmap gi (lsp-implementation) - nmap gt (lsp-type-definition) - nmap rn (lsp-rename) - nmap [g (lsp-previous-diagnostic) - nmap ]g (lsp-next-diagnostic) - nmap K (lsp-hover) - nnoremap lsp#scroll(+4) - nnoremap lsp#scroll(-4) - - let g:lsp_format_sync_timeout = 500 - autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') - - " refer to doc to add more commands + setlocal omnifunc=lsp#complete + setlocal signcolumn=yes + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap gd (lsp-definition) + nmap gs (lsp-document-symbol-search) + nmap gS (lsp-workspace-symbol-search) + nmap gr (lsp-references) + nmap gi (lsp-implementation) + nmap gt (lsp-type-definition) + nmap rn (lsp-rename) + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + nmap K (lsp-hover) + nnoremap lsp#scroll(+4) + nnoremap lsp#scroll(-4) + + let g:lsp_format_sync_timeout = 500 + autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') + + " refer to doc to add more commands endfunction augroup lsp_install - au! - " call s:on_lsp_buffer_enabled only for languages that has the server registered. - autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() + au! + " call s:on_lsp_buffer_enabled only for languages that has the server registered. + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END " Register ccls C++ lanuage server. if executable('ccls') - au User lsp_setup call lsp#register_server({ - \ 'name': 'ccls', - \ 'cmd': {server_info->['ccls']}, - \ 'root_uri': {server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), '.ccls'))}, - \ 'initialization_options': {'cache': {'directory': expand('~/.cache/ccls') }}, - \ 'allowlist': ['c', 'cpp', 'objc', 'objcpp', 'cc'], - \ }) + au User lsp_setup call lsp#register_server({ + \ 'name': 'ccls', + \ 'cmd': {server_info->['ccls']}, + \ 'root_uri': {server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), '.ccls'))}, + \ 'initialization_options': {'cache': {'directory': expand('~/.cache/ccls') }}, + \ 'allowlist': ['c', 'cpp', 'objc', 'objcpp', 'cc'], + \ }) endif " settings for pyls @@ -337,16 +336,16 @@ nnoremap :UndotreeToggle "{{{ undo if has("persistent_undo") - let target_path = expand('~/.cache/undodir') + let target_path = expand('~/.cache/undodir') - " create the directory and any parent directories - " if the location does not exist. - if !isdirectory(target_path) - call mkdir(target_path, "p", 0700) - endif + " create the directory and any parent directories + " if the location does not exist. + if !isdirectory(target_path) + call mkdir(target_path, "p", 0700) + endif - let &undodir=target_path - set undofile + let &undodir=target_path + set undofile endif "}}} @@ -354,7 +353,7 @@ endif " settings for sumatraPDF let g:vimtex_view_general_viewer = 'SumatraPDF' let g:vimtex_view_general_options - \ = '-reuse-instance -forward-search @tex @line @pdf' + \ = '-reuse-instance -forward-search @tex @line @pdf' "let g:vimtex_view_general_options_latexmk = '-reuse-instance' let g:tex_flavor='latex' let g:vimtex_quickfix_mode=0 @@ -540,18 +539,13 @@ if has('win32') endif "}}} -"{{{ lf.vim -let g:NERDTreeHijackNetrw = 0 " Add this line if you use NERDTree -let g:lf_replace_netrw = 1 " Open lf when vim opens a directory -"}}} - " {{{ Gui winpos 300 0 set lines=64 columns=120 set guioptions-=T set guioptions-=r -set guifont=Sarasa\ Mono\ SC\ Nerd:h16 +set guifont=Sarasa\ Mono\ SC\ Nerd:h14 " }}} "{{{ deoplete keymap @@ -591,3 +585,25 @@ set updatetime=100 " {{{ identLine "let g:indentLine_setColors = 0 " }}} + +" {{{ Neoformat +" Enable alignment +" let g:neoformat_basic_format_align = 1 + +" Enable tab to spaces conversion +" let g:neoformat_basic_format_retab = 1 + +" Enable trimmming of trailing whitespace +" let g:neoformat_basic_format_trim = 1 + +" let g:neoformat_only_msg_on_error = 1 + +let g:neoformat_c_clangformat={ + \ 'exe': 'clang-format', + \ 'stdin' : 1, + \ 'args': ['-style=file:'.expand('~/clang-format')], + \ } + +let g:neoformat_enabled_c = ['clangformat'] +" }}} +