Skip to content
This repository was archived by the owner on Feb 23, 2025. It is now read-only.

Commit

Permalink
Merge pull request #452 from liquidz/next_release
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
liquidz authored Dec 24, 2022
2 parents f62b8dc + 1a82485 commit 68a322d
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 43 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com].

== Unreleased (dev)
// {{{
=== Added
* Added `g:iced#navigate#jump_fallback_command` option.
** This option allows you to fallback another command when jumping to definition is failed.
* Added `IcedPrintLastStackTrace` command.

=== Changed
* Update instant connecting for nbb to use `deno` command if you don't have `nbb` command.
** Deno must be v1.28 or later. (npm support is required)
* Bumped cider-nrepl to 0.29.0.
* Bumped iced-nrepl to 1.2.474.
// }}}

== 3.13.3174 (2022-12-04)
// {{{
Expand Down
9 changes: 8 additions & 1 deletion autoload/iced/nrepl/connect.vim
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,14 @@ endfunction
function! s:__instant_nbb(port) abort
" NOTE: A job in vim may terminate when outputting long texts such as stack traces.
" So ignoring the standard output etc.
let cmd = ['sh', '-c', printf('nbb nrepl-server :port %s > /dev/null 2>&1', a:port)]
if executable('nbb')
let nbb_cmd = 'nbb'
elseif executable('deno')
let nbb_cmd = 'deno run -A npm:nbb@latest'
else
return iced#message#error('command_not_found', 'nbb or deno')
endif
let cmd = ['sh', '-c', printf('%s nrepl-server :port %s > /dev/null 2>&1', nbb_cmd, a:port)]
let s:running_job = iced#job_start(cmd)

let s:is_auto_connecting = v:true
Expand Down
72 changes: 51 additions & 21 deletions autoload/iced/nrepl/eval.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
let s:save_cpo = &cpoptions
set cpoptions&vim

let g:iced#nrepl#eval#ignoring_vars_in_stacktrace =
\ get(g:, 'iced#nrepl#eval#ignoring_vars_in_stacktrace', [])

function! s:parse_error(err) abort
" Clojure 1.9 or above
let err = matchstr(a:err, ', compiling:(.\+:\d\+:\d\+)')
Expand Down Expand Up @@ -42,19 +45,23 @@ function! iced#nrepl#eval#err(err, ...) abort
endif
endfunction

" NOTE: Each stacktrace format is like below
" {'file': 'form-init11159443384990986285.clj',
" 'flags': ['project', 'repl', 'clj'],
" 'ns': 'foo.core',
" 'name': 'foo.core$boom/invokeStatic',
" 'method': 'invokeStatic',
" 'line': 9,
" 'fn': 'boom',
" 'class': 'foo.core$boom',
" 'file-url': 'file:/private/tmp/foo/ src/foo/core.clj',
" 'type': 'clj',
" 'var': 'foo.core/boom'}
function! s:print_stack_trace(resp) abort
" NOTE: Response format
" {'data': '{:foo :bar}',
" 'message': 'foo',
" 'class': 'clojure.lang.ExceptionInfo',
" 'stacktace': [
" {'file': 'form-init11159443384990986285.clj',
" 'flags': ['project', 'repl', 'clj'],
" 'ns': 'foo.core',
" 'name': 'foo.core$boom/invokeStatic',
" 'method': 'invokeStatic',
" 'line': 9,
" 'fn': 'boom',
" 'class': 'foo.core$boom',
" 'file-url': 'file:/private/tmp/foo/ src/foo/core.clj',
" 'type': 'clj',
" 'var': 'foo.core/boom'}]}
function! s:print_stack_trace(resp, ignores) abort
let errors = []

if type(a:resp) == v:t_list
Expand All @@ -63,23 +70,38 @@ function! s:print_stack_trace(resp) abort
if empty(class) | continue | endif
let stacktrace = get(resp, 'stacktrace', [])
if empty(stacktrace) | continue | endif
let data = get(resp, 'data')
let message = get(resp, 'message')

call iced#buffer#stdout#append(class)
if !empty(data)
call iced#buffer#stdout#append(printf(' data %s', data))
endif

for item in stacktrace
let name = get(item, 'name')
let file = get(item, 'file')
let var = get(item, 'var')
let file_url = get(item, 'file-url')
let line = get(item, 'line')
let text = printf(' at %s(%s:%d)', name, file, line)
call iced#buffer#stdout#append(text)
let normalized_file_url = (empty(file_url) ? '' : iced#util#normalize_path(file_url))

let file_url = get(item, 'file-url')
let var = get(item, 'var')
if ! empty(file_url)
let name = (empty(var) ? name : var)
if index(a:ignores, name) != -1
continue
endif

call iced#buffer#stdout#append(printf(' at %s (%s:%d)',
\ name,
\ empty(normalized_file_url) ? file : normalized_file_url,
\ line))

if ! empty(normalized_file_url)
call add(errors, {
\ 'filename': iced#util#normalize_path(file_url),
\ 'filename': normalized_file_url,
\ 'lnum': line,
\ 'end_lnum': line,
\ 'text': (empty(var) ? name : var),
\ 'text': name,
\ 'type': 'E',
\ })
endif
Expand Down Expand Up @@ -146,7 +168,9 @@ function! iced#nrepl#eval#out(resp) abort
endif

if has_key(a:resp, 'ex') && !empty(a:resp['ex'])
call iced#nrepl#op#cider#stacktrace(funcref('s:print_stack_trace'))
call iced#nrepl#op#cider#analyze_last_stacktrace({resp ->
\ s:print_stack_trace(resp, g:iced#nrepl#eval#ignoring_vars_in_stacktrace)
\ })
endif

call iced#nrepl#eval#err(get(a:resp, 'err', ''), opt)
Expand Down Expand Up @@ -323,5 +347,11 @@ function! iced#nrepl#eval#clear_inline_result() abort
call iced#system#get('virtual_text').clear()
endfunction

function! iced#nrepl#eval#print_last_stacktrace() abort
return iced#nrepl#op#cider#analyze_last_stacktrace({resp ->
\ s:print_stack_trace(resp, [])
\ })
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo
20 changes: 16 additions & 4 deletions autoload/iced/nrepl/navigate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ let s:qualified_key_def_prefix_regex = printf('\(%s\)',
\ {_, v -> printf('%s\s\+', v)}),
\ '\|'))

let g:iced#navigate#jump_fallback_command = get(g:, 'iced#navigate#jump_fallback_command', '')

function! s:raw_jump(jump_cmd, path, line, column) abort
call iced#util#add_curpos_to_jumplist()
if expand('%:p') !=# a:path
Expand Down Expand Up @@ -195,7 +197,7 @@ function! s:jump_to_qualified_keyword_by_clj_kondo(keyword) abort
let definition = kondo.keyword_definition(expand('%:p'), a:keyword)

if empty(definition)
return iced#message#error('jump_not_found')
return s:jump_fallback()
endif

let path = get(definition, 'filename', '')
Expand Down Expand Up @@ -239,7 +241,7 @@ function! s:jump_to_qualified_keyword(keyword) abort
endif

if empty(path)
return iced#message#error('jump_not_found')
return s:jump_fallback()
endif
endif

Expand Down Expand Up @@ -287,7 +289,7 @@ function! s:jump(base_symbol, jump_cmd, resp) abort
return s:jump_to_local_definition(local_def)
endif
else
return iced#message#error('jump_not_found')
return s:jump_fallback()
endif
endif

Expand Down Expand Up @@ -333,7 +335,7 @@ function! s:jump(base_symbol, jump_cmd, resp) abort
let line = d['row']
let column = d['col']
else
return iced#message#error('jump_not_found')
return s:jump_fallback()
endif
else
let path = a:resp['file']
Expand All @@ -344,6 +346,16 @@ function! s:jump(base_symbol, jump_cmd, resp) abort

call s:raw_jump(a:jump_cmd, path, line, column)
endfunction

function! s:jump_fallback() abort
if g:iced#navigate#jump_fallback_command ==# ''
return iced#message#error('jump_not_found')
else
call iced#message#info('jump_fallback', g:iced#navigate#jump_fallback_command)
execute g:iced#navigate#jump_fallback_command
endif
endfunction

" }}}

" iced#nrepl#navigate#test {{{
Expand Down
5 changes: 3 additions & 2 deletions autoload/iced/nrepl/op/cider.vim
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ function! iced#nrepl#op#cider#clojuredocs_refresh_cache(export_edn_url, callback
endfunction " }}}

""" stacktrace {{{
function! iced#nrepl#op#cider#stacktrace(callback) abort
function! iced#nrepl#op#cider#analyze_last_stacktrace(callback) abort
if !iced#nrepl#is_connected() | return iced#message#error('not_connected') | endif
call iced#nrepl#send({
\ 'id': iced#nrepl#id(),
\ 'op': 'stacktrace',
\ 'op': 'analyze-last-stacktrace',
\ 'session': iced#nrepl#current_session(),
\ 'callback': a:callback,
\ })
Expand Down Expand Up @@ -324,6 +324,7 @@ call iced#nrepl#register_handler('test-var-query', function('iced#nrepl#extend_r
call iced#nrepl#register_handler('retest', function('iced#nrepl#extend_responses_handler'))
call iced#nrepl#register_handler('ns-path', function('iced#nrepl#path_translation_handler', [['path']]))
call iced#nrepl#register_handler('stacktrace', function('iced#nrepl#extend_responses_handler'))
call iced#nrepl#register_handler('analyze-last-stacktrace', function('iced#nrepl#extend_responses_handler'))

let &cpo = s:save_cpo
unlet s:save_cpo
2 changes: 1 addition & 1 deletion autoload/iced/palette.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let s:default_palette = [
\ 'QuitCljsRepl', 'CycleSession',
\ 'EvalNs', 'Undef', 'UndefAllInNs', 'UnaliasNs',
\ 'Require', 'RequireAll', 'Refresh', 'RefreshAll', 'RefreshClear',
\ 'PrintLast',
\ 'PrintLast', 'PrintLastStackTrace',
\ 'TestNs', 'TestAll', 'TestRedo', 'TestSpecCheck', 'TestRerunLast',
\ 'TestBufferOpen',
\ 'StdoutBufferOpen', 'StdoutBufferClear', 'StdoutBufferClose', 'StdoutBufferToggle',
Expand Down
2 changes: 1 addition & 1 deletion bin/iced
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SCRIPT_DIR=$(cd $(dirname $0); pwd)
PROJECT_DIR=$(cd $SCRIPT_DIR; cd ..; pwd)
VERSION=$(grep 'Version: ' ${SCRIPT_DIR}/../doc/vim-iced.txt | cut -d' ' -f2)

BASE_DEPENDENCIES='nrepl/nrepl:1.0.0 refactor-nrepl/refactor-nrepl:3.6.0 cider/cider-nrepl:0.28.7 com.github.liquidz/iced-nrepl:1.2.468'
BASE_DEPENDENCIES='nrepl/nrepl:1.0.0 refactor-nrepl/refactor-nrepl:3.6.0 cider/cider-nrepl:0.29.0 com.github.liquidz/iced-nrepl:1.2.474'
BASE_MIDDLEWARES='cider.nrepl/wrap-classpath cider.nrepl/wrap-clojuredocs cider.nrepl/wrap-complete cider.nrepl/wrap-debug cider.nrepl/wrap-format cider.nrepl/wrap-info cider.nrepl/wrap-macroexpand cider.nrepl/wrap-ns cider.nrepl/wrap-out cider.nrepl/wrap-refresh cider.nrepl/wrap-stacktrace cider.nrepl/wrap-spec cider.nrepl/wrap-test cider.nrepl/wrap-trace cider.nrepl/wrap-undef cider.nrepl/wrap-xref refactor-nrepl.middleware/wrap-refactor iced.nrepl/wrap-iced'

CLJS_DEPENDENCIES='cider/piggieback:0.5.3'
Expand Down
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{:paths ["clj/repl"]
:deps {nrepl/nrepl {:mvn/version "1.0.0"}
refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}
cider/cider-nrepl {:mvn/version "0.28.7"}
com.github.liquidz/iced-nrepl {:mvn/version "1.2.468"}}
cider/cider-nrepl {:mvn/version "0.29.0"}
com.github.liquidz/iced-nrepl {:mvn/version "1.2.474"}}
:__middlewares__
["cider.nrepl/wrap-classpath"
"cider.nrepl/wrap-clojuredocs"
Expand Down
Loading

0 comments on commit 68a322d

Please sign in to comment.