mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
Fix Objective C language support (#4215)
This commit is contained in:
parent
669a164d44
commit
172579a260
@ -14,6 +14,7 @@ let s:self.__aliases = {
|
|||||||
\ 'typescriptreact' : 'TypeScript React',
|
\ 'typescriptreact' : 'TypeScript React',
|
||||||
\ 'python' : 'Python',
|
\ 'python' : 'Python',
|
||||||
\ 'java' : 'Java',
|
\ 'java' : 'Java',
|
||||||
|
\ 'objc' : 'Objective-C',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,27 +155,35 @@ function! SpaceVim#layers#lang#c#config() abort
|
|||||||
call SpaceVim#mapping#gd#add('cpp',
|
call SpaceVim#mapping#gd#add('cpp',
|
||||||
\ function('s:go_to_def'))
|
\ function('s:go_to_def'))
|
||||||
" TODO: add stdin suport flex -t lexer.l | gcc -o lexer.o -xc -
|
" TODO: add stdin suport flex -t lexer.l | gcc -o lexer.o -xc -
|
||||||
let runner1 = {
|
let c_runner = {
|
||||||
\ 'exe' : 'gcc',
|
\ 'exe' : 'gcc',
|
||||||
\ 'targetopt' : '-o',
|
\ 'targetopt' : '-o',
|
||||||
\ 'opt' : ['-std=' . s:clang_std.c] + s:clang_flag + ['-xc', '-'],
|
\ 'opt' : ['-std=' . s:clang_std.c] + s:clang_flag + ['-xc', '-'],
|
||||||
\ 'usestdin' : 1,
|
\ 'usestdin' : 1,
|
||||||
\ }
|
\ }
|
||||||
call SpaceVim#plugins#runner#reg_runner('c', [runner1, '#TEMP#'])
|
call SpaceVim#plugins#runner#reg_runner('c', [c_runner, '#TEMP#'])
|
||||||
call SpaceVim#mapping#space#regesit_lang_mappings('c', function('s:language_specified_mappings'))
|
call SpaceVim#mapping#space#regesit_lang_mappings('c', function('s:language_specified_mappings'))
|
||||||
let runner2 = {
|
let cpp_runner = {
|
||||||
\ 'exe' : 'g++',
|
\ 'exe' : 'g++',
|
||||||
\ 'targetopt' : '-o',
|
\ 'targetopt' : '-o',
|
||||||
\ 'opt' : ['-std=' . s:clang_std.cpp] + s:clang_flag + ['-xc++', '-'],
|
\ 'opt' : ['-std=' . s:clang_std.cpp] + s:clang_flag + ['-xc++', '-'],
|
||||||
\ 'usestdin' : 1,
|
\ 'usestdin' : 1,
|
||||||
\ }
|
\ }
|
||||||
call SpaceVim#plugins#runner#reg_runner('cpp', [runner2, '#TEMP#'])
|
call SpaceVim#plugins#runner#reg_runner('cpp', [cpp_runner, '#TEMP#'])
|
||||||
if !empty(s:c_repl_command)
|
if !empty(s:c_repl_command)
|
||||||
call SpaceVim#plugins#repl#reg('c', s:c_repl_command)
|
call SpaceVim#plugins#repl#reg('c', s:c_repl_command)
|
||||||
else
|
else
|
||||||
call SpaceVim#plugins#repl#reg('c', 'igcc')
|
call SpaceVim#plugins#repl#reg('c', 'igcc')
|
||||||
endif
|
endif
|
||||||
call SpaceVim#mapping#space#regesit_lang_mappings('cpp', funcref('s:language_specified_mappings'))
|
call SpaceVim#mapping#space#regesit_lang_mappings('cpp', funcref('s:language_specified_mappings'))
|
||||||
|
let objc_runner = {
|
||||||
|
\ 'exe' : 'gcc',
|
||||||
|
\ 'targetopt' : '-o',
|
||||||
|
\ 'opt' : ['-std=' . s:clang_std.objc] + s:clang_flag + ['-xobjc', '-'],
|
||||||
|
\ 'usestdin' : 1,
|
||||||
|
\ }
|
||||||
|
call SpaceVim#plugins#runner#reg_runner('objc', [objc_runner, '#TEMP#'])
|
||||||
|
call SpaceVim#mapping#space#regesit_lang_mappings('objc', funcref('s:language_specified_mappings'))
|
||||||
call SpaceVim#plugins#projectmanager#reg_callback(funcref('s:update_clang_flag'))
|
call SpaceVim#plugins#projectmanager#reg_callback(funcref('s:update_clang_flag'))
|
||||||
if executable('clang')
|
if executable('clang')
|
||||||
let g:neomake_c_enabled_makers = ['clang']
|
let g:neomake_c_enabled_makers = ['clang']
|
||||||
@ -189,6 +197,7 @@ function! SpaceVim#layers#lang#c#config() abort
|
|||||||
if s:enable_clang_syntax
|
if s:enable_clang_syntax
|
||||||
auto FileType c,cpp call s:highlight()
|
auto FileType c,cpp call s:highlight()
|
||||||
endif
|
endif
|
||||||
|
au BufRead,BufNewFile *.m set filetype=objc
|
||||||
augroup END
|
augroup END
|
||||||
call add(g:spacevim_project_rooter_patterns, '.clang')
|
call add(g:spacevim_project_rooter_patterns, '.clang')
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
@ -392,22 +401,32 @@ function! s:update_runner(argv, fts) abort
|
|||||||
let default_std = 0
|
let default_std = 0
|
||||||
endif
|
endif
|
||||||
if index(a:fts, 'c') !=# -1
|
if index(a:fts, 'c') !=# -1
|
||||||
let runner1 = {
|
let c_runner = {
|
||||||
\ 'exe' : 'gcc',
|
\ 'exe' : 'gcc',
|
||||||
\ 'targetopt' : '-o',
|
\ 'targetopt' : '-o',
|
||||||
\ 'opt' : a:argv + (default_std ? [] : ['-std=' . s:clang_std.c]) + s:clang_flag + ['-xc', '-'],
|
\ 'opt' : a:argv + (default_std ? [] : ['-std=' . s:clang_std.c]) + s:clang_flag + ['-xc', '-'],
|
||||||
\ 'usestdin' : 1,
|
\ 'usestdin' : 1,
|
||||||
\ }
|
\ }
|
||||||
call SpaceVim#plugins#runner#reg_runner('c', [runner1, '#TEMP#'])
|
call SpaceVim#plugins#runner#reg_runner('c', [c_runner, '#TEMP#'])
|
||||||
endif
|
endif
|
||||||
if index(a:fts, 'cpp') !=# -1
|
if index(a:fts, 'cpp') !=# -1
|
||||||
let runner2 = {
|
let cpp_runner = {
|
||||||
\ 'exe' : 'g++',
|
\ 'exe' : 'g++',
|
||||||
\ 'targetopt' : '-o',
|
\ 'targetopt' : '-o',
|
||||||
\ 'opt' : a:argv + (default_std ? [] : ['-std=' . s:clang_std.cpp]) + s:clang_flag + ['-xc++', '-'],
|
\ 'opt' : a:argv + (default_std ? [] : ['-std=' . s:clang_std.cpp]) + s:clang_flag + ['-xc++', '-'],
|
||||||
\ 'usestdin' : 1,
|
\ 'usestdin' : 1,
|
||||||
\ }
|
\ }
|
||||||
call SpaceVim#plugins#runner#reg_runner('cpp', [runner2, '#TEMP#'])
|
call SpaceVim#plugins#runner#reg_runner('cpp', [cpp_runner, '#TEMP#'])
|
||||||
|
endif
|
||||||
|
" update clang_flag for objective-c
|
||||||
|
if index(a:fts, 'objc') !=# -1
|
||||||
|
let cpp_runner = {
|
||||||
|
\ 'exe' : 'gcc',
|
||||||
|
\ 'targetopt' : '-o',
|
||||||
|
\ 'opt' : a:argv + (default_std ? [] : ['-std=' . s:clang_std.objc]) + s:clang_flag + ['-xobjc', '-'],
|
||||||
|
\ 'usestdin' : 1,
|
||||||
|
\ }
|
||||||
|
call SpaceVim#plugins#runner#reg_runner('objc', [cpp_runner, '#TEMP#'])
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" }}}
|
" }}}
|
||||||
|
@ -33,6 +33,7 @@ To use this configuration layer, update the custom configuration file with:
|
|||||||
- code completion
|
- code completion
|
||||||
- syntax checking
|
- syntax checking
|
||||||
- formatting
|
- formatting
|
||||||
|
- syntax highlighting: Objective-C(`.m`), C(`.c`), CPP(`.cpp`)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ This is a list of programming languages supported in SpaceVim:
|
|||||||
| AutoHotkey | [lang#autohotkey](https://spacevim.org/layers/lang/autohotkey/) | |
|
| AutoHotkey | [lang#autohotkey](https://spacevim.org/layers/lang/autohotkey/) | |
|
||||||
| Bash, Fish, zsh | [lang#sh](https://spacevim.org/layers/lang/sh/) | |
|
| Bash, Fish, zsh | [lang#sh](https://spacevim.org/layers/lang/sh/) | |
|
||||||
| C# | [lang#csharp](https://spacevim.org/layers/lang/csharp/) | |
|
| C# | [lang#csharp](https://spacevim.org/layers/lang/csharp/) | |
|
||||||
| C/C++ | [lang#c](https://spacevim.org/layers/lang/c/) | |
|
| C/C++/Objective-C | [lang#c](https://spacevim.org/layers/lang/c/) | |
|
||||||
| Clojure | [lang#clojure](https://spacevim.org/layers/lang/clojure/) | |
|
| Clojure | [lang#clojure](https://spacevim.org/layers/lang/clojure/) | |
|
||||||
| CoffeeScript | [lang#coffeescript](https://spacevim.org/layers/lang/coffeescript/) | |
|
| CoffeeScript | [lang#coffeescript](https://spacevim.org/layers/lang/coffeescript/) | |
|
||||||
| Crystal | [lang#crystal](https://spacevim.org/layers/lang/crystal/) | |
|
| Crystal | [lang#crystal](https://spacevim.org/layers/lang/crystal/) | |
|
||||||
@ -224,7 +224,6 @@ Before adding these languages, we need to know:
|
|||||||
| NXT-G | | |
|
| NXT-G | | |
|
||||||
| Oberon | | |
|
| Oberon | | |
|
||||||
| Object Rexx | | |
|
| Object Rexx | | |
|
||||||
| Objective-C | | |
|
|
||||||
| Occam | | |
|
| Occam | | |
|
||||||
| OpenCL | | |
|
| OpenCL | | |
|
||||||
| OpenEdge ABL | | |
|
| OpenEdge ABL | | |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user