Browse Source

add neoformat

Signed-off-by: surenyi <surenyi82@qq.com>
master
surenyi 2 years ago
parent
commit
e50fe9a254
  1. 2
      linter/.clang-format
  2. 116
      vim9/vimrc

2
linter/.clang-format

@ -123,5 +123,5 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Cpp03 Standard: Cpp03
TabWidth: 4 TabWidth: 4
UseTab: AlignWithSpaces UseTab: Never
... ...

116
vim9/vimrc

@ -106,6 +106,7 @@ Plug 'kana/vim-textobj-line'
Plug 'wellle/targets.vim' Plug 'wellle/targets.vim'
Plug 'fatih/vim-go' Plug 'fatih/vim-go'
Plug 'sbdchd/neoformat'
Plug 'jlanzarotta/bufexplorer' Plug 'jlanzarotta/bufexplorer'
Plug 'joshdick/onedark.vim' Plug 'joshdick/onedark.vim'
@ -131,7 +132,6 @@ Plug 'mbbill/undotree'
Plug 'voldikss/vim-floaterm' Plug 'voldikss/vim-floaterm'
Plug 'voldikss/LeaderF-floaterm' Plug 'voldikss/LeaderF-floaterm'
Plug 'skywind3000/asyncrun.vim' Plug 'skywind3000/asyncrun.vim'
Plug 'ptzz/lf.vim'
Plug 'lervag/vimtex' Plug 'lervag/vimtex'
@ -190,7 +190,6 @@ Plug 'machakann/vim-highlightedyank'
call plug#end() call plug#end()
let g:deoplete#enable_at_startup = 1 let g:deoplete#enable_at_startup = 1
let g:lf_map_keys = 0
"}}} "}}}
"{{{ mapleader=SPACE "{{{ mapleader=SPACE
@ -204,9 +203,9 @@ nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
"{{{ colorscheme "{{{ colorscheme
" Important!! " Important!!
if has('termguicolors') if has('termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors set termguicolors
endif endif
set background=dark set background=dark
@ -266,43 +265,43 @@ let g:airline_theme='nord'
"{{{ vim-lsp "{{{ vim-lsp
function! s:on_lsp_buffer_enabled() abort function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete setlocal omnifunc=lsp#complete
setlocal signcolumn=yes setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition) nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search) nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search) nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references) nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation) nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition) nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename) nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic) nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic) nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover) nmap <buffer> K <plug>(lsp-hover)
nnoremap <buffer> <expr><c-f> lsp#scroll(+4) nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
nnoremap <buffer> <expr><c-d> lsp#scroll(-4) nnoremap <buffer> <expr><c-d> lsp#scroll(-4)
let g:lsp_format_sync_timeout = 500 let g:lsp_format_sync_timeout = 500
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
" refer to doc to add more commands " refer to doc to add more commands
endfunction endfunction
augroup lsp_install augroup lsp_install
au! au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered. " 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() autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END augroup END
" Register ccls C++ lanuage server. " Register ccls C++ lanuage server.
if executable('ccls') if executable('ccls')
au User lsp_setup call lsp#register_server({ au User lsp_setup call lsp#register_server({
\ 'name': 'ccls', \ 'name': 'ccls',
\ 'cmd': {server_info->['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'))}, \ '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') }}, \ 'initialization_options': {'cache': {'directory': expand('~/.cache/ccls') }},
\ 'allowlist': ['c', 'cpp', 'objc', 'objcpp', 'cc'], \ 'allowlist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
\ }) \ })
endif endif
" settings for pyls " settings for pyls
@ -337,16 +336,16 @@ nnoremap <F5> :UndotreeToggle<CR>
"{{{ undo "{{{ undo
if has("persistent_undo") if has("persistent_undo")
let target_path = expand('~/.cache/undodir') let target_path = expand('~/.cache/undodir')
" create the directory and any parent directories " create the directory and any parent directories
" if the location does not exist. " if the location does not exist.
if !isdirectory(target_path) if !isdirectory(target_path)
call mkdir(target_path, "p", 0700) call mkdir(target_path, "p", 0700)
endif endif
let &undodir=target_path let &undodir=target_path
set undofile set undofile
endif endif
"}}} "}}}
@ -354,7 +353,7 @@ endif
" settings for sumatraPDF " settings for sumatraPDF
let g:vimtex_view_general_viewer = 'SumatraPDF' let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options 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:vimtex_view_general_options_latexmk = '-reuse-instance'
let g:tex_flavor='latex' let g:tex_flavor='latex'
let g:vimtex_quickfix_mode=0 let g:vimtex_quickfix_mode=0
@ -540,18 +539,13 @@ if has('win32')
endif 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 " {{{ Gui
winpos 300 0 winpos 300 0
set lines=64 columns=120 set lines=64 columns=120
set guioptions-=T set guioptions-=T
set guioptions-=r set guioptions-=r
set guifont=Sarasa\ Mono\ SC\ Nerd:h16 set guifont=Sarasa\ Mono\ SC\ Nerd:h14
" }}} " }}}
"{{{ deoplete keymap "{{{ deoplete keymap
@ -591,3 +585,25 @@ set updatetime=100
" {{{ identLine " {{{ identLine
"let g:indentLine_setColors = 0 "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']
" }}}

Loading…
Cancel
Save