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
Standard: Cpp03
TabWidth: 4
UseTab: AlignWithSpaces
UseTab: Never
...

116
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 <silent> <localleader> :<c-u>WhichKey ','<CR>
"{{{ colorscheme
" Important!!
if has('termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[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 <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
nnoremap <buffer> <expr><c-d> 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 <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
nnoremap <buffer> <expr><c-d> 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 <F5> :UndotreeToggle<CR>
"{{{ 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']
" }}}

Loading…
Cancel
Save