简体   繁体   中英

Vim settings for C and C++?

Creating new files with c extension comes with processing errors. I was using Clion on my other machines but after giving a thought, I decided to move to vim where I do most of my other languages work.

My dotfile for c and plugins?

Plugin 'luchermitte/lh-cpp'
Plugin 'cscope.vim'
Plugin 'c.vim'

" += C.vim config
let  g:C_UseTool_cmake    = 'yes'
let  g:C_UseTool_doxygen = 'yes'

Errors: I want to resolve these errors.

Error detected while processing /Users/frrank/.vim/bundle/lh-cpp/ftplugin/c/c_menu.vim:
line   43:
E117: Unknown function: lh#option#get
E15: Invalid expression: lh#option#get('c_menu_priority', '50', 'g')
line   44:
E117: Unknown function: lh#option#get
E15: Invalid expression: lh#option#get('c_menu_name',     '&C++', 'g')
line   66:
E121: Undefined variable: s:menu_prio
E15: Invalid expression: 'amenu <silent> '.s:menu_prio.'.100 '.escape(s:menu_name.'.-100-', '\ '). ' <Nop>'
line   69:
E121: Undefined variable: s:menu_prio
E15: Invalid expression: 'amenu <silent> '.s:menu_prio.'.100.1 '. escape(s:menu_name.'.&Help.&Contents', '\ '). ' :help lh-cpp-readme.txt<cr>'
line   72:
E121: Undefined variable: s:menu_prio
E15: Invalid expression: 'amenu <silent> '.s:menu_prio.'.100.2 '. escape(s:menu_name.'.&Help.&Features', '\ '). ' :help lh-cpp-features<cr>'
line   75:
E121: Undefined variable: s:menu_prio
E15: Invalid expression: 'amenu <silent> '.s:menu_prio.'.100.3 '. escape(s:menu_name.'.&Help.&First Steps', '\ '). ' :help lh-cpp-first-steps<cr>'
line   79:
E121: Undefined variable: s:menu_prio
E15: Invalid expression: 'amenu <silent> '.s:menu_prio.'.100.20.10 '. escape(s:menu_name.'.&Help.Code &snippets.&Brackets', '\ '). ' :help brackets-for-C<cr>'
line   82:
E121: Undefined variable: s:menu_prio
E15: Invalid expression: 'amenu <silent> '.s:menu_prio.'.100.20.20 '. escape(s:menu_name.'.&Help.Code &snippets.&C snippets', '\ '). ' :help C_control-statements<cr>'
Error detected while processing /Users/frrank/.vim/bundle/lh-cpp/ftplugin/c/c_pvs-2-qf.vim:

Error detected while processing /Users/frrank/.vim/bundle/lh-cpp/ftplugin/c/c_snippets.vim:
line   65:
E492: Not an editor command: :Brackets #if\ 0 #endif -insert=0 -nl -trigger=<localleader>0
line   68:
E492: Not an editor command: :Brackets #if\ 0 #else!mark!\n#endif -insert=0 -nl -trigger=<localleader>1
line   81:
E492: Not an editor command:   Inoreabbr <buffer> <silent> if <C-R>=lh#cpp#snippets#def_abbr('if ', '\<c-f\>if(!cursorhere!){!mark!}!mark!')<cr>
line   95:
E492: Not an editor command:   Inoreabbr <buffer> <silent> elif <C-R>=lh#cpp#snippets#def_abbr('elif ', '\<c-f\>else if(!cursorhere!) {!mark!}!mark!')<cr>
line  109:
E492: Not an editor command:   Inoreabbr <buffer> <silent> else <C-R>=lh#cpp#snippets#insert_if_not_before('else ', '\<c-f\>else{!cursorhere!}!mark!', 'if')<cr><c-f>
line  123:
E492: Not an editor command:   Inoreabbr <buffer> <silent> for <C-R>=lh#cpp#snippets#def_abbr('for ', { '! lh#cpp#use_cpp11()': '\<c-f\>for(!cursorhere!;!mark!;!mark!){!mark!}!mark!
', '  lh#cpp#use_cpp11()': '\<c-f\>for(!cursorhere!){!mark!}!mark!' })<cr>
line  133:
E492: Not an editor command:   Inoreabbr <buffer> <silent> while <C-R>=lh#cpp#snippets#def_abbr('while ', '\<c-f\>while(!cursorhere!){!mark!}!mark!')<cr>
line  152:
E492: Not an editor command:   Inoreabbr <buffer> <silent> do <C-R>=lh#cpp#snippets#def_abbr('do ', '\<c-f\>do{!cursorhere!}while(!mark!);!mark!')<cr><c-f>
line  179:
E492: Not an editor command:   Inoreabbr <buffer> <silent> switch <C-R>=lh#cpp#snippets#def_abbr('switch ', '\<c-f\>switch(!cursorhere!){!mark!}!mark!')<cr>
line  202:
E492: Not an editor command:   Brackets /* */ -visual=0
line  203:
E492: Not an editor command:   Brackets /* */ -visual=0 -trigger=<kDivide><kMultiply>
line  205:
E492: Not an editor command:   Brackets /* */ -insert=0 -trigger=<m-v>
Error detected while processing /Users/frrank/.vim/bundle/lh-cpp/ftplugin/c/previewWord.vim:
line   46:
E117: Unknown function: lh#mapping#plug
line   50:
E117: Unknown function: lh#mapping#plug
line   64:
E117: Unknown function: lh#menu#def_toggle_item
line   66:
E117: Unknown function: lh#mapping#plug 

My lh-cpp plugin comes with dependencies. Whatever plugin manager you use, which isn't VAM nor vim-flavour (the only two that really support dependencies), you'll have to explicitly declare the dependencies for your plugin manager.

I've listed everything you need in the readme . It shouldn't be very complex to adapt it to another plugin manager than the ones I've listed. In case I've made a mistake, or if there are other errors, don't be afraid to open an issue.

What is sure: don't mix plugin managers. Choose one and convert everything you come over to its syntax.

PS: I don't use c.vim, I cannot guarantee you won't observe any conflicts by using both. lh-cpp don't come with snippets for lib C functions, but with those , it has its own Doxygen related features . And (CMake based) compilation , code indexation, project management , etc. are deported to other plugins. See my post on quora on the subject.

The issue is with Plugin 'luchermitte/lh-cpp' as its a plugin pack for c development which contains installing them using Plug not Vundle that made a conflict in my env.

So either you have to remove lh-cpp or change vundle to something like bundle etc.

Also cleared my thoughts with this installation process

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM