diff options
| author | CodingCellist <teh6@st-andrews.ac.uk> | 2020-09-05 21:37:11 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-05 21:37:11 +0200 | 
| commit | 3baafd5c336d18d87898ae87f16df7cd76bc8d65 (patch) | |
| tree | 3bd6787bde3c5713fd5cfc7c962d60ac4b3dac50 /autoload | |
| parent | b0124dc88082f5ed8c96faa16d3b334d38f5949f (diff) | |
| download | vim-polyglot-3baafd5c336d18d87898ae87f16df7cd76bc8d65.tar.gz vim-polyglot-3baafd5c336d18d87898ae87f16df7cd76bc8d65.zip | |
Add support for Idris2, closes #534 (#535)
Diffstat (limited to '')
| -rw-r--r-- | autoload/cargo/quickfix.vim | 3 | ||||
| -rw-r--r-- | autoload/polyglot.vim | 44 | ||||
| -rw-r--r-- | autoload/rustfmt.vim | 4 | ||||
| -rw-r--r-- | autoload/sleuth.vim | 2 | 
4 files changed, 50 insertions, 3 deletions
| diff --git a/autoload/cargo/quickfix.vim b/autoload/cargo/quickfix.vim index e1e5b9d2..cce7fcbb 100644 --- a/autoload/cargo/quickfix.vim +++ b/autoload/cargo/quickfix.vim @@ -1,7 +1,8 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1  function! cargo#quickfix#CmdPre() abort -    if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo' +    if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo' && +         \ &makeprg =~ '\V\^cargo\ \.\*'          " Preserve the current directory, and 'lcd' to the nearest Cargo file.          let b:rust_compiler_cargo_qf_has_lcd = haslocaldir()          let b:rust_compiler_cargo_qf_prev_cd = getcwd() diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index 3753dc8e..eca7e304 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -212,6 +212,50 @@ func! polyglot#DetectReFiletype()    endfor  endfunc +func! polyglot#DetectIdrFiletype() +  for lnum in range(1, min([line("$"), 5])) +    let line = getline(lnum) +    if line =~# '^\s*--.*[Ii]dris \=1' +      setf idris | return +    endif +    if line =~# '^\s*--.*[Ii]dris \=2' +      setf idris2 | return +    endif +  endfor +  for lnum in range(1, min([line("$"), 30])) +    let line = getline(lnum) +    if line =~# '^pkgs =.*' +      setf idris | return +    endif +    if line =~# '^depends =.*' +      setf idris2 | return +    endif +    if line =~# '^%language \(TypeProviders\|ElabReflection\)' +      setf idris | return +    endif +    if line =~# '^%language PostfixProjections' +      setf idris2 | return +    endif +    if line =~# '^%access .*' +      setf idris | return +    endif +    if exists("g:filetype_idr") +      exe "setf " . g:filetype_idr | return +    endif +  endfor +  setf idris2 | return +endfunc + +func! polyglot#DetectLidrFiletype() +  for lnum in range(1, min([line("$"), 200])) +    let line = getline(lnum) +    if line =~# '^>\s*--.*[Ii]dris \=1' +      setf lidris | return +    endif +  endfor +  setf lidris2 | return +endfunc +  " Restore 'cpoptions'  let &cpo = s:cpo_save  unlet s:cpo_save diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim index 514e4147..60e2029e 100644 --- a/autoload/rustfmt.vim +++ b/autoload/rustfmt.vim @@ -65,12 +65,12 @@ endfunction  function! s:RustfmtConfigOptions()      let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')      if l:rustfmt_toml !=# '' -        return '--config-path '.fnamemodify(l:rustfmt_toml, ":p") +        return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p"))      endif      let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';')      if l:_rustfmt_toml !=# '' -        return '--config-path '.fnamemodify(l:_rustfmt_toml, ":p") +        return '--config-path '.shellescape(fnamemodify(l:_rustfmt_toml, ":p"))      endif      " Default to edition 2018 in case no rustfmt.toml was found. diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index a912cda4..e70169cb 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -103,6 +103,7 @@ let s:globs = {    \ 'i3config': '*.i3.config,*.i3config,i3.config,i3config',    \ 'icalendar': '*.ics',    \ 'idris': '*.idr,*.lidr,idris-response', +  \ 'idris2': '*.idr,*.ipkg,idris-response',    \ 'ion': '*.ion',    \ 'javascript': '*.js,*._js,*.bones,*.cjs,*.es,*.es6,*.frag,*.gs,*.jake,*.jsb,*.jscad,*.jsfl,*.jsm,*.jss,*.mjs,*.njs,*.pac,*.sjs,*.ssjs,*.xsjs,*.xsjslib,Jakefile',    \ 'javascriptreact': '*.jsx', @@ -116,6 +117,7 @@ let s:globs = {    \ 'kotlin': '*.kt,*.ktm,*.kts',    \ 'ledger': '*.ldg,*.ledger,*.journal',    \ 'less': '*.less', +  \ 'lidris2': '*.lidr',    \ 'lilypond': '*.ly,*.ily',    \ 'litcoffee': '*.litcoffee,*.coffee.md',    \ 'livescript': '*.ls,*._ls,Slakefile', | 
