Comments (12)
Definitely possible, the syntax checkers checked in to this repo currently only support swiftpm since that's such a common case, but neomake has a direct swiftc example that just parses the current file:
from swift.vim.
Kinda related: #142
from swift.vim.
Thanks. But I'm confused. I don't understand how your module works with Syntastic or how I would integrate neomake with your module or what swiftpm does exactly (I know what a package manager is but I have no idea why it's involved in syntax checking).
So what do I have to do, exactly, to get syntax checking on a standalone file working?
from swift.vim.
Also, another point of confusion for me is that I've got swift syntax checking working on Ubuntu. But when I run swift pacakage --version
on my mac, I get this error:
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-pacakage (No such file or directory)
So I'm not sure how to get this working on my Mac. I thought the package manager would be installed with xcode, though.
from swift.vim.
You have a typo, it's swift package --version
from swift.vim.
You have a few options:
- You can use this plugin and neomake, this plugin will provide highlighting while neomake would provide the syntax checking
- If you prefer your current syntax checker you can create a new checker in this repo similar to https://github.com/keith/swift.vim/blob/master/syntax_checkers/swift/swiftpm.vim but replace the fact that it's calling
swift build
and callswiftc -parse
instead.
from swift.vim.
doh! thanks. I should put my glasses on, I guess. :)
from swift.vim.
Note that SwiftPM isn't actually only doing syntax checking, the way it is setup in this repo it actually does a build of your package, and reports the compiler errors back
from swift.vim.
OK, I think this is starting to make more sense now. Thank you.
from swift.vim.
I took a stab at trying to create a new syntax checker (though my vimscript skills are about on par with my swift skills) called swiftc.vim
:
if exists('g:loaded_syntastic_swift_swiftc_checker')
finish
endif
let g:loaded_syntastic_swift_swiftc_checker = 1
if !exists('g:syntastic_swift_swiftc_executable')
let g:syntastic_swift_swiftc_executable = 'swiftc'
endif
if !exists('g:syntastic_swift_swiftc_arguments')
let g:syntastic_swift_swiftc_arguments = '-parse'
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_swift_swiftc_IsAvailable() dict
"if !executable(self.getExec())
" return 0
"endif
return 1
endfunction
function! SyntaxCheckers_swift_swiftc_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'fname': '',
\ 'args': g:syntastic_swift_swiftc_arguments })
let errorformat =
\ '%f:%l:%c: error: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'swift',
\ 'name': 'swiftc',
\ 'exec': g:syntastic_swift_swiftc_executable })
let &cpo = s:save_cpo
unlet s:save_cpo
It doesn't work, though.
from swift.vim.
OK, I did a little bit more noodling and got something working:
if exists('g:loaded_syntastic_swift_swiftc_checker')
finish
endif
let g:loaded_syntastic_swift_swiftc_checker = 1
if !exists('g:syntastic_swift_swiftc_executable')
let g:syntastic_swift_swiftc_executable = 'swiftc'
endif
if !exists('g:syntastic_swift_swiftc_arguments')
let g:syntastic_swift_swiftc_arguments = ''
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_swift_swiftc_IsAvailable() dict
"if !executable(self.getExec())
" return 0
"endif
return 1
endfunction
function! SyntaxCheckers_swift_swiftc_GetLocList() dict
let file = fnameescape(expand("%:p"))
let makeprg = self.makeprgBuild({
\ 'fname': file,
\ 'args': [''] })
let errorformat = '%f:%l:%c: error: %m,%W%f:%l:%c: warning: %m,%Z%\s%#^~%#,%-G%.%#'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'swift',
\ 'name': 'swiftc',
\ 'exec': g:syntastic_swift_swiftc_executable })
let &cpo = s:save_cpo
unlet s:save_cpo
Are you interested in having me create a patch for this? I'm sure what I have needs to be fixed up and better integrated with your plugin, though.
from swift.vim.
Yep looks good! If you put it in that directory named swiftc.vim
it should "just work" if you enable it in your syntastic config
from swift.vim.
Related Issues (20)
- Number highlighting HOT 2
- ctags config errors HOT 1
- Number ranges aren't displaying properly HOT 2
- Multi line comment continuation is broken HOT 4
- Add @escaping
- where closure is not indenting correctly
- Use tabs for indentation, only in Swift HOT 1
- Multi-line String Literals Aren't Correctly Highlighted HOT 2
- Included ALE linters breaks `swiftlint` with ALE HOT 4
- Highlighting issue when escaping triple quotation marks
- Indent issue
- Incorrect indent after line
- Documentation: PlugInstall HOT 1
- Use swift's language server HOT 1
- Fix triple slash continuations
- Add Code Folding Support HOT 3
- swiftAttributes detected incorrectly.
- Indentation for nested switch/case and for cases with code on the same line is incorrect. HOT 1
- Can we PR indent/swift.vim to vim/vim HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift.vim.