summaryrefslogtreecommitdiffstats
path: root/autoload
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2019-03-29 20:30:36 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2019-03-29 20:30:36 +0100
commita55b6aa3aa797c989a4979a13a5bd2ae11cfd4a5 (patch)
tree0ec7670cabfdf1b5fa3545cee9ee9d6ca7c8ad32 /autoload
parent1d45a6d4f094127b113470d7710695b280224933 (diff)
downloadvim-polyglot-3.7.1.tar.gz
vim-polyglot-3.7.1.zip
Remove grapqhl, fixes #387v3.7.1
Diffstat (limited to 'autoload')
-rw-r--r--autoload/crystal_lang.vim44
-rw-r--r--autoload/db/adapter/ecto.vim24
-rw-r--r--autoload/go/config.vim25
-rw-r--r--autoload/rustfmt.vim3
4 files changed, 82 insertions, 14 deletions
diff --git a/autoload/crystal_lang.vim b/autoload/crystal_lang.vim
index fb344d5e..56221246 100644
--- a/autoload/crystal_lang.vim
+++ b/autoload/crystal_lang.vim
@@ -37,21 +37,45 @@ function! s:run_cmd(cmd) abort
return s:P.system(a:cmd)
endfunction
-function! s:find_root_by_spec(d) abort
- let dir = finddir('spec', a:d . ';')
- if dir ==# ''
+function! s:find_root_by(search_dir, d) abort
+ let found_dir = finddir(a:search_dir, a:d . ';')
+ if found_dir ==# ''
return ''
endif
- " Note: ':h:h' for {root}/spec/ -> {root}/spec -> {root}
- return fnamemodify(dir, ':p:h:h')
+ " Note: ':h:h' for {root}/{search_dir}/ -> {root}/{search_dir} -> {root}
+ return fnamemodify(found_dir, ':p:h:h')
+endfunction
+
+" Search the root directory containing a 'spec/' and a 'src/' directories.
+"
+" Searching for the 'spec/' directory is not enough: for example the crystal
+" compiler has a 'cr_sources/src/spec/' directory that would otherwise give the root
+" directory as 'cr_source/src/' instead of 'cr_sources/'.
+function! s:find_root_by_spec_and_src(d) abort
+ " Search for 'spec/'
+ let root = s:find_root_by('spec', a:d)
+ " Check that 'src/' is also there
+ if root !=# '' && isdirectory(root . '/src')
+ return root
+ endif
+
+ " Search for 'src/'
+ let root = s:find_root_by('src', a:d)
+ " Check that 'spec/' is also there
+ if root !=# '' && isdirectory(root . '/spec')
+ return root
+ endif
+
+ " Cannot find a directory containing both 'src/' and 'spec/'
+ return ''
endfunction
function! crystal_lang#entrypoint_for(file_path) abort
let parent_dir = fnamemodify(a:file_path, ':p:h')
- let root_dir = s:find_root_by_spec(parent_dir)
+ let root_dir = s:find_root_by_spec_and_src(parent_dir)
if root_dir ==# ''
- " No spec diretory found. No need to make temporary file
+ " No spec directory found. No need to make temporary file
return a:file_path
endif
@@ -232,7 +256,7 @@ endfunction
function! crystal_lang#run_all_spec(...) abort
let path = a:0 == 0 ? expand('%:p:h') : a:1
- let root_path = s:find_root_by_spec(path)
+ let root_path = s:find_root_by_spec_and_src(path)
if root_path ==# ''
return s:echo_error("'spec' directory is not found")
endif
@@ -250,9 +274,9 @@ function! crystal_lang#run_current_spec(...) abort
let source_dir = fnamemodify(path, ':h')
" /foo/bar
- let root_dir = s:find_root_by_spec(source_dir)
+ let root_dir = s:find_root_by_spec_and_src(source_dir)
if root_dir ==# ''
- return s:echo_error("'spec' directory is not found")
+ return s:echo_error("Root directory with 'src/' and 'spec/' not found")
endif
" src
diff --git a/autoload/db/adapter/ecto.vim b/autoload/db/adapter/ecto.vim
new file mode 100644
index 00000000..54ee3396
--- /dev/null
+++ b/autoload/db/adapter/ecto.vim
@@ -0,0 +1,24 @@
+if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'elixir') != -1
+ finish
+endif
+
+let s:path = expand('<sfile>:h')
+let s:cmd = join(['mix', 'run', '--no-start', '--no-compile', shellescape(s:path.'/get_repos.exs')])
+
+function! s:repo_list() abort
+ return map(systemlist(s:cmd), 'split(v:val)')
+endfunction
+
+function! db#adapter#ecto#canonicalize(url) abort
+ for l:item in s:repo_list()
+ let l:name = get(l:item, 0)
+ let l:url = get(l:item, 1)
+ if !empty(l:name) && 'ecto:'.l:name ==# a:url
+ return l:url
+ endif
+ endfor
+endfunction
+
+function! db#adapter#ecto#complete_opaque(url) abort
+ return map(s:repo_list(), 'v:val[0]')
+endfunction
diff --git a/autoload/go/config.vim b/autoload/go/config.vim
index 7cb7f05e..7c840c53 100644
--- a/autoload/go/config.vim
+++ b/autoload/go/config.vim
@@ -214,6 +214,12 @@ function! go#config#DebugCommands() abort
return g:go_debug_commands
endfunction
+function! go#config#LspLog() abort
+ " make sure g:go_lsp_log is set so that it can be added to easily.
+ let g:go_lsp_log = get(g:, 'go_lsp_log', [])
+ return g:go_lsp_log
+endfunction
+
function! go#config#SetDebugDiag(value) abort
let g:go_debug_diag = a:value
endfunction
@@ -239,15 +245,27 @@ function! go#config#SetTemplateAutocreate(value) abort
endfunction
function! go#config#MetalinterCommand() abort
- return get(g:, "go_metalinter_command", "")
+ return get(g:, "go_metalinter_command", "gometalinter")
endfunction
function! go#config#MetalinterAutosaveEnabled() abort
- return get(g:, 'go_metalinter_autosave_enabled', ['vet', 'golint'])
+ let l:default_enabled = ["vet", "golint"]
+
+ if go#config#MetalinterCommand() == "golangci-lint"
+ let l:default_enabled = ["govet", "golint"]
+ endif
+
+ return get(g:, "go_metalinter_autosave_enabled", default_enabled)
endfunction
function! go#config#MetalinterEnabled() abort
- return get(g:, "go_metalinter_enabled", ['vet', 'golint', 'errcheck'])
+ let l:default_enabled = ["vet", "golint", "errcheck"]
+
+ if go#config#MetalinterCommand() == "golangci-lint"
+ let l:default_enabled = ["govet", "golint"]
+ endif
+
+ return get(g:, "go_metalinter_enabled", default_enabled)
endfunction
function! go#config#MetalinterDisabled() abort
@@ -448,7 +466,6 @@ function! go#config#EchoGoInfo() abort
return get(g:, "go_echo_go_info", 1)
endfunction
-
" Set the default value. A value of "1" is a shortcut for this, for
" compatibility reasons.
if exists("g:go_gorename_prefill") && g:go_gorename_prefill == 1
diff --git a/autoload/rustfmt.vim b/autoload/rustfmt.vim
index 59ab3d3b..96fffb26 100644
--- a/autoload/rustfmt.vim
+++ b/autoload/rustfmt.vim
@@ -234,6 +234,9 @@ function! rustfmt#Cmd()
endfunction
function! rustfmt#PreWrite()
+ if !filereadable(expand("%@"))
+ return
+ endif
if rust#GetConfigVar('rustfmt_autosave_if_config_present', 0)
if findfile('rustfmt.toml', '.;') !=# '' || findfile('.rustfmt.toml', '.;') !=# ''
let b:rustfmt_autosave = 1