Skip to content

Commit

Permalink
Merge pull request #430 from liquidz/dev
Browse files Browse the repository at this point in the history
3.10.4
  • Loading branch information
liquidz authored Aug 9, 2022
2 parents 8952108 + 55ddd9d commit b2c963a
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 31 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. This change

== Unreleased (dev)

== 3.10.4 (2022-08-10)
// {{{
=== Changed
* Changed `IcedBrowseReferences` and `IcedBrowseDependencies` results to sort by filename.
* Changed `IcedBrowseReferences` and `IcedBrowseDependencies` to jump instantly if there is only one candidate.

=== Fixed
* Fixed `IcedEvalOuterTopList` to work corrently on the beginning of forms.
// }}}

== 3.10.3 (2022-08-07)
// {{{
=== Changed
Expand Down
6 changes: 4 additions & 2 deletions autoload/iced/component/clj_kondo.vim
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ function! s:kondo.references(ns_name, var_name) abort

let ana = self.analysis()
let usages = get(ana, 'var-usages', [])
return filter(usages, {_, usage ->
let usages = filter(usages, {_, usage ->
\ (get(usage, 'to', '') ==# a:ns_name
\ && get(usage, 'name', '') ==# var_name)})
return sort(usages, {x, y -> (x['filename'] ==# y['filename']) ? 0 : (x['filename'] < y['filename']) ? -1 : 1})
endfunction

function! s:kondo.dependencies(ns_name, var_name) abort
Expand All @@ -276,8 +277,9 @@ function! s:kondo.dependencies(ns_name, var_name) abort
let deps_dict = iced#util#list_to_dict(dependencies,
\ {d -> printf('%s/%s', get(d, 'to', ''), get(d, 'name', ''))}, {d -> v:true})

return filter(definitions, {_, definition ->
let definitions = filter(definitions, {_, definition ->
\ has_key(deps_dict, printf('%s/%s', get(definition, 'ns', ''), get(definition, 'name', '')))})
return sort(definitions, {x, y -> (x['filename'] ==# y['filename']) ? 0 : (x['filename'] < y['filename']) ? -1 : 1})
endfunction

function! s:kondo.used_ns_list() abort
Expand Down
2 changes: 1 addition & 1 deletion autoload/iced/component/clj_kondo/sqlite.vim
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function! s:kondo.references(ns_name, var_name) abort

" Remove quote if exists
let var_name = trim(a:var_name, "'")
let sql = s:I.interpolate('select * from var_usages where json_extract(json, "$.to") = "${ns_name}" and json_extract(json, "$.name") = "${var_name}"',
let sql = s:I.interpolate('select * from var_usages where json_extract(json, "$.to") = "${ns_name}" and json_extract(json, "$.name") = "${var_name}" order by json_extract(json, "$.filename")',
\ {'ns_name': a:ns_name,
\ 'var_name': var_name})
let res = trim(system(printf('sqlite3 %s ''%s''', self.db_name, sql)))
Expand Down
65 changes: 41 additions & 24 deletions autoload/iced/nrepl/navigate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ let s:L = s:V.import('Data.List')
let g:iced#related_ns#tail_patterns =
\ get(g:, 'iced#related_ns#tail_patterns', ['', '-test', '-spec', '\.spec'])

let g:iced#var_references#cache_dir = get(g:, 'iced#var_references#cache_dir', '/tmp')
let g:iced#navigate#prefer_local_jump = get(g:, 'iced#navigate#prefer_local_jump', v:false)

" definitions to jump to qualified keyword
Expand All @@ -28,15 +27,31 @@ let s:qualified_key_def_prefix_regex = printf('\(%s\)',
\ {_, v -> printf('%s\s\+', v)}),
\ '\|'))

function! s:apply_mode_to_file(mode, file) abort
let cmd = ':edit'
function! s:raw_jump(jump_cmd, path, line, column) abort
call iced#util#add_curpos_to_jumplist()
if expand('%:p') !=# a:path
call iced#system#get('ex_cmd').exe(printf(':keepjumps %s %s', a:jump_cmd, a:path))
endif
call cursor(a:line, a:column)
normal! zz

redraw!
endfunction

function! s:mode_to_command(mode) abort
let cmd = 'edit'
if a:mode ==# 'v'
let cmd = ':split'
let cmd = 'split'
elseif a:mode ==# 't'
let cmd = ':tabedit'
let cmd = 'tabedit'
endif
return cmd
endfunction

function! s:apply_mode_to_file(mode, file) abort
let cmd = s:mode_to_command(a:mode)
call iced#system#get('tagstack').add_here()
call iced#system#get('ex_cmd').exe(printf('%s %s', cmd, a:file))
call iced#system#get('ex_cmd').exe(printf(':%s %s', cmd, a:file))
endfunction

" iced#nrepl#navigate#open_ns {{{
Expand Down Expand Up @@ -327,14 +342,7 @@ function! s:jump(base_symbol, jump_cmd, resp) abort
endif
endif

call iced#util#add_curpos_to_jumplist()
if expand('%:p') !=# path
call iced#system#get('ex_cmd').exe(printf(':keepjumps %s %s', a:jump_cmd, path))
endif
call cursor(line, column)
normal! zz

redraw!
call s:raw_jump(a:jump_cmd, path, line, column)
endfunction
" }}}

Expand All @@ -361,16 +369,25 @@ function! s:set_xref_resp_to_quickfix(key, resp) abort
endif

let xrefs = copy(a:resp[a:key])
call filter(xrefs, {_, v -> filereadable(v['file'])})
call map(xrefs, {_, v -> {
\ 'filename': v['file'],
\ 'text': (has_key(v, 'doc') ? printf('%s: %s', v['name'], v['doc']) : v['name']),
\ 'lnum': v['line'],
\ }})
if empty(xrefs) | return iced#message#info('not_found') | endif

call iced#system#get('quickfix').setloclist(win_getid(), xrefs)
call iced#system#get('ex_cmd').silent_exe(':lwindow')

if len(xrefs) == 1
let xref = xrefs[0]
let file = get(xref, 'file', '')
if filereadable(file)
call s:raw_jump('edit', file, get(xref, 'line', 1), 1)
endif
else
call filter(xrefs, {_, v -> filereadable(v['file'])})
call map(xrefs, {_, v -> {
\ 'filename': v['file'],
\ 'text': (has_key(v, 'doc') ? printf('%s: %s', v['name'], v['doc']) : v['name']),
\ 'lnum': v['line'],
\ }})
if empty(xrefs) | return iced#message#info('not_found') | endif

call iced#system#get('quickfix').setloclist(win_getid(), xrefs)
call iced#system#get('ex_cmd').silent_exe(':lwindow')
endif
endfunction

let s:fn_refs_callback = function('s:set_xref_resp_to_quickfix', ['fn-refs'])
Expand Down
2 changes: 1 addition & 1 deletion autoload/iced/paredit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ endfunction
function! s:select_current_top_list() abort
let current_line = line('.')
" Search nearest top form
let start_line = search('^\S', 'bW')
let start_line = search('^\S', 'bcW')
" Move to first opening parenthesis
call search('(', 'cW')
" WARN: `normal! %` may be move to closing parenthesis in comments.
Expand Down
2 changes: 1 addition & 1 deletion doc/vim-iced.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*vim-iced.txt* Clojure interactive development environment for Vim8/Neovim

Version: 3.10.3
Version: 3.10.4
Author : Masashi Iizuka <[email protected]>
License: MIT LICENSE

Expand Down
2 changes: 1 addition & 1 deletion ftplugin/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if exists('g:loaded_vim_iced')
finish
endif
let g:loaded_vim_iced = 1
let g:vim_iced_version = 31003
let g:vim_iced_version = 31004
let g:vim_iced_home = expand('<sfile>:p:h:h')
" NOTE: https://github.com/vim/vim/commit/162b71479bd4dcdb3a2ef9198a1444f6f99e6843
" Add functions for defining and placing signs.
Expand Down
12 changes: 11 additions & 1 deletion test/paredit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,17 @@ function! s:suite.get_top_list_in_comment_test() abort
call s:assert.equals(res['code'], "(foo\n (bar))")
call s:buf.stop_dummy()

" FIXME
" the beginning of the form
call s:buf.start_dummy([
\ '(dummy)',
\ '',
\ '|(foo',
\ ' (bar))',
\ ])
let res = iced#paredit#get_top_list_in_comment()
call s:assert.equals(res['code'], "(foo\n (bar))")
call s:buf.stop_dummy()

" reader conditionals
call s:buf.start_dummy([
\ '#?(:clj :foo',
Expand Down

0 comments on commit b2c963a

Please sign in to comment.