Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update language layer #1161

Merged
merged 14 commits into from Dec 23, 2017
20 changes: 20 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,20 @@
# PR Prelude

Thank you for working on SpaceVim! :)

**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**

- [ ] I have read and understood SpaceVim's [CONTRIBUTING][cont] document.
- [ ] I have read and understood SpaceVim's [CODE_OF_CONDUCT][code] document.
- [ ] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [ ] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**

# Why this change is necessary and useful

[Please explain **in detail** why the changes in this PR are needed.]

[cont]: https://github.com/SpaceVim/SpaceVim/blob/dev/CONTRIBUTING.md
[code]: https://github.com/SpaceVim/SpaceVim/blob/dev/CODE_OF_CONDUCT.md
23 changes: 23 additions & 0 deletions .github/SUPPORT.md
@@ -0,0 +1,23 @@
![Bountysource](https://spacevim.org/img/bountysource.png)

If you want to support SpaceVim, please check out our [Bountysource campaign](https://www.bountysource.com/teams/spacevim).

Also, you can buy me a coffee:

<a href='https://ko-fi.com/A538L6H' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi4.png?v=f' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

| wechat | alipay |
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| <img src="https://spacevim.org/img/weixin.png" height="150" width="150"> | <img src="https://spacevim.org/img/zhifubao.png" height="150" width="150"> |

Bitcoin: 1DtuVeg81c2L9NEhDaVTAAbrCR3pN5xPFv

# Current Sponsors

These are the companies or individuals contributing a monthly amount to help sustain SpaceVim's development.
See the [Bountysource campaign](https://www.bountysource.com/teams/spacevim) for more details.

| Date | Description |
| --------- | --------------------------------------------- |
| 2017-2-23 | user from wechat contributed ¥40 to SpaceVim |
| 2017-2-14 | user from wechat contributed ¥100 to SpaceVim |
6 changes: 0 additions & 6 deletions autoload/SpaceVim/layers/lang.vim
@@ -1,11 +1,5 @@
function! SpaceVim#layers#lang#plugins() abort
let plugins = [
\ ['groenewege/vim-less', { 'on_ft' : ['less']}],
\ ['cakebaker/scss-syntax.vim', { 'on_ft' : ['scss','sass']}],
\ ['hail2u/vim-css3-syntax', { 'on_ft' : ['css','scss','sass']}],
\ ['ap/vim-css-color', { 'on_ft' : ['css','scss','sass','less','styl']}],
\ ['othree/html5.vim', { 'on_ft' : ['html']}],
\ ['wavded/vim-stylus', { 'on_ft' : ['stylus']}],
\ ['digitaltoad/vim-jade', { 'on_ft' : ['jade']}],
\ ['juvenn/mustache.vim', { 'on_ft' : ['mustache']}],
\ ['kchmck/vim-coffee-script', { 'on_ft' : ['coffee']}],
Expand Down
14 changes: 4 additions & 10 deletions autoload/SpaceVim/layers/lang/haskell.vim
Expand Up @@ -4,19 +4,13 @@ function! SpaceVim#layers#lang#haskell#plugins() abort
\ ['pbrisbin/vim-syntax-shakespeare', { 'on_ft': 'haskell' }],
\ ]

if !s:use_lsp
if SpaceVim#layers#lsp#check_filetype('haskell')
call add(plugins, ['eagletmt/neco-ghc', { 'on_ft': 'haskell' }])
endif

return plugins
endfunction

let s:use_lsp = 0

function! SpaceVim#layers#lang#haskell#set_variable(var) abort
let s:use_lsp = get(a:var, 'use_lsp', 0) && has('nvim') && executable('hie')
endfunction

function! SpaceVim#layers#lang#haskell#config() abort
let g:haskellmode_completion_ghc = 0

Expand All @@ -26,7 +20,7 @@ function! SpaceVim#layers#lang#haskell#config() abort
call SpaceVim#mapping#space#regesit_lang_mappings('haskell',
\ funcref('s:on_ft'))

if s:use_lsp
if SpaceVim#layers#lsp#check_filetype('haskell')
call SpaceVim#mapping#gd#add('haskell',
\ function('SpaceVim#lsp#go_to_def'))
call SpaceVim#lsp#reg_server('haskell', ['hie', '--lsp'])
Expand All @@ -35,14 +29,14 @@ function! SpaceVim#layers#lang#haskell#config() abort
augroup SpaceVim_lang_haskell
autocmd!

if !s:use_lsp
if SpaceVim#layers#lsp#check_filetype('haskell')
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
endif
augroup END
endfunction

function! s:on_ft() abort
if s:use_lsp
if SpaceVim#layers#lsp#check_filetype('haskell')
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>

call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
Expand Down
11 changes: 11 additions & 0 deletions autoload/SpaceVim/layers/lang/html.vim
@@ -0,0 +1,11 @@
function! SpaceVim#layers#lang#html#plugins() abort
let plugins = [
\ ['groenewege/vim-less', { 'on_ft' : ['less']}],
\ ['cakebaker/scss-syntax.vim', { 'on_ft' : ['scss','sass']}],
\ ['hail2u/vim-css3-syntax', { 'on_ft' : ['css','scss','sass']}],
\ ['ap/vim-css-color', { 'on_ft' : ['css','scss','sass','less','styl']}],
\ ['othree/html5.vim', { 'on_ft' : ['html']}],
\ ['wavded/vim-stylus', { 'on_ft' : ['stylus']}],
\ ]
return plugins
endfunction
10 changes: 3 additions & 7 deletions autoload/SpaceVim/layers/lang/javascript.vim
Expand Up @@ -13,7 +13,7 @@ function! SpaceVim#layers#lang#javascript#plugins() abort
\ ['pangloss/vim-javascript', { 'on_ft': 'javascript' }],
\ ]

if !s:use_lsp
if !SpaceVim#layers#lsp#check_filetype('javascript')
call add(plugins, ['ternjs/tern_for_vim', {
\ 'on_ft': 'javascript', 'build' : 'npm install' }])
call add(plugins, ['carlitux/deoplete-ternjs', { 'on_ft': [
Expand All @@ -23,12 +23,9 @@ function! SpaceVim#layers#lang#javascript#plugins() abort
return plugins
endfunction

let s:use_lsp = 0
let s:auto_fix = 0

function! SpaceVim#layers#lang#javascript#set_variable(var) abort
let s:use_lsp = get(a:var, 'use_lsp', 0) && has('nvim')
\ && executable('javascript-typescript-stdio')
let s:auto_fix = get(a:var, 'auto_fix', 0)
endfunction

Expand All @@ -46,8 +43,7 @@ function! SpaceVim#layers#lang#javascript#config() abort
call SpaceVim#mapping#space#regesit_lang_mappings('javascript',
\ funcref('s:on_ft'))

if s:use_lsp
call SpaceVim#lsp#reg_server('javascript', ['javascript-typescript-stdio'])
if SpaceVim#layers#lsp#check_filetype('javascript')
call SpaceVim#mapping#gd#add('javascript',
\ function('SpaceVim#lsp#go_to_def'))
else
Expand Down Expand Up @@ -81,7 +77,7 @@ function! s:on_ft() abort
inoremap <silent><buffer> <C-j>g <Esc>:ImportJSGoto<CR>a
" }}}

if s:use_lsp
if SpaceVim#layers#lsp#check_filetype('javascript')
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>

call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
Expand Down
32 changes: 32 additions & 0 deletions autoload/SpaceVim/layers/lsp.vim
Expand Up @@ -60,5 +60,37 @@ function! SpaceVim#layers#lsp#config() abort

let g:LanguageClient_autoStart = 1
" }}}
for ft in s:enabled_fts
call SpaceVim#lsp#reg_server(ft, s:lsp_servers[ft])
endfor
endfunction

let s:enabled_fts = []

let s:lsp_servers = {
\ 'javascript' : ['javascript-typescript-stdio'],
\ 'haskell' : ['hie', '--lsp'],
\ }

function! SpaceVim#layers#lsp#set_variable(var) abort
let override = get(a:var, 'override_cmd', {})
if !empty(override)
call extend(s:lsp_servers, override, 'force')
endif
for ft in get(a:var, 'filetypes', [])
let cmd = get(s:lsp_servers, ft, [''])[0]
if empty(cmd)
call SpaceVim#logger#warn('Failed to find the lsp server command for ' . ft)
else
if executable(cmd)
call add(s:enabled_fts, ft)
else
call SpaceVim#logger#warn('Failed to enable lsp for ' . ft . ', ' . cmd . 'is not executable!')
endif
endif
endfor
endfunction

function! SpaceVim#layers#lsp#check_filetype(ft) abort
return index(s:enabled_fts, a:ft) != -1
endfunction
8 changes: 4 additions & 4 deletions autoload/SpaceVim/logger.vim
Expand Up @@ -3,22 +3,22 @@ let s:LOGGER = SpaceVim#api#import('logger')
call s:LOGGER.set_name('SpaceVim')
call s:LOGGER.set_level(1)
call s:LOGGER.set_silent(0)
call s:LOGGER.set_verbose(2)
call s:LOGGER.set_verbose(1)

function! SpaceVim#logger#info(msg)
function! SpaceVim#logger#info(msg) abort

call s:LOGGER.info(a:msg)

endfunction

function! SpaceVim#logger#warn(msg)
function! SpaceVim#logger#warn(msg) abort

call s:LOGGER.warn(a:msg)

endfunction


function! SpaceVim#logger#error(msg)
function! SpaceVim#logger#error(msg) abort

call s:LOGGER.error(a:msg)

Expand Down