diff --git a/autoload/SpaceVim/api/language.vim b/autoload/SpaceVim/api/language.vim index f4195b7f7..b3b478cd7 100644 --- a/autoload/SpaceVim/api/language.vim +++ b/autoload/SpaceVim/api/language.vim @@ -14,6 +14,7 @@ let s:self.__aliases = { \ 'typescriptreact' : 'TypeScript React', \ 'python' : 'Python', \ 'java' : 'Java', + \ 'objc' : 'Objective-C', \ } diff --git a/autoload/SpaceVim/layers/lang/c.vim b/autoload/SpaceVim/layers/lang/c.vim index ed5d48042..a142a95c7 100644 --- a/autoload/SpaceVim/layers/lang/c.vim +++ b/autoload/SpaceVim/layers/lang/c.vim @@ -155,27 +155,35 @@ function! SpaceVim#layers#lang#c#config() abort call SpaceVim#mapping#gd#add('cpp', \ function('s:go_to_def')) " TODO: add stdin suport flex -t lexer.l | gcc -o lexer.o -xc - - let runner1 = { + let c_runner = { \ 'exe' : 'gcc', \ 'targetopt' : '-o', \ 'opt' : ['-std=' . s:clang_std.c] + s:clang_flag + ['-xc', '-'], \ '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')) - let runner2 = { + let cpp_runner = { \ 'exe' : 'g++', \ 'targetopt' : '-o', \ 'opt' : ['-std=' . s:clang_std.cpp] + s:clang_flag + ['-xc++', '-'], \ '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) call SpaceVim#plugins#repl#reg('c', s:c_repl_command) else call SpaceVim#plugins#repl#reg('c', 'igcc') endif 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')) if executable('clang') let g:neomake_c_enabled_makers = ['clang'] @@ -189,6 +197,7 @@ function! SpaceVim#layers#lang#c#config() abort if s:enable_clang_syntax auto FileType c,cpp call s:highlight() endif + au BufRead,BufNewFile *.m set filetype=objc augroup END call add(g:spacevim_project_rooter_patterns, '.clang') if has('nvim') @@ -392,22 +401,32 @@ function! s:update_runner(argv, fts) abort let default_std = 0 endif if index(a:fts, 'c') !=# -1 - let runner1 = { + let c_runner = { \ 'exe' : 'gcc', \ 'targetopt' : '-o', \ 'opt' : a:argv + (default_std ? [] : ['-std=' . s:clang_std.c]) + s:clang_flag + ['-xc', '-'], \ 'usestdin' : 1, \ } - call SpaceVim#plugins#runner#reg_runner('c', [runner1, '#TEMP#']) + call SpaceVim#plugins#runner#reg_runner('c', [c_runner, '#TEMP#']) endif if index(a:fts, 'cpp') !=# -1 - let runner2 = { + let cpp_runner = { \ 'exe' : 'g++', \ 'targetopt' : '-o', \ 'opt' : a:argv + (default_std ? [] : ['-std=' . s:clang_std.cpp]) + s:clang_flag + ['-xc++', '-'], \ '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 endfunction " }}} diff --git a/docs/layers/lang/c.md b/docs/layers/lang/c.md index f0bc3dd99..458ede3e2 100644 --- a/docs/layers/lang/c.md +++ b/docs/layers/lang/c.md @@ -33,6 +33,7 @@ To use this configuration layer, update the custom configuration file with: - code completion - syntax checking - formatting +- syntax highlighting: Objective-C(`.m`), C(`.c`), CPP(`.cpp`) ## Configuration diff --git a/wiki/en/programming-languages.md b/wiki/en/programming-languages.md index 1090890ce..f08da94ad 100644 --- a/wiki/en/programming-languages.md +++ b/wiki/en/programming-languages.md @@ -20,7 +20,7 @@ This is a list of programming languages supported in SpaceVim: | AutoHotkey | [lang#autohotkey](https://spacevim.org/layers/lang/autohotkey/) | | | Bash, Fish, zsh | [lang#sh](https://spacevim.org/layers/lang/sh/) | | | 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/) | | | CoffeeScript | [lang#coffeescript](https://spacevim.org/layers/lang/coffeescript/) | | | Crystal | [lang#crystal](https://spacevim.org/layers/lang/crystal/) | | @@ -224,7 +224,6 @@ Before adding these languages, we need to know: | NXT-G | | | | Oberon | | | | Object Rexx | | | -| Objective-C | | | | Occam | | | | OpenCL | | | | OpenEdge ABL | | |