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

Add matched text to ALEFindReferences -quickfix for tsserver #4464

Open
bogdan opened this issue Feb 27, 2023 · 1 comment · May be fixed by #4898
Open

Add matched text to ALEFindReferences -quickfix for tsserver #4464

bogdan opened this issue Feb 27, 2023 · 1 comment · May be fixed by #4898
Assignees

Comments

@bogdan
Copy link

bogdan commented Feb 27, 2023

Information

VIM version

NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3

Operating System: iOS

What went wrong

Finding references in quickfix using tsserver doesn't populate matching line text

Reproducing the bug

  1. Create a file like below
  2. Point cursor on A.
  3. Run :ALEFindReferences -quickfix.
class A {
}
new A();

Expected Result:

lib/file.ts|1 col 7| class A {
lib/file.ts|3 col 7| new A();

Actual Result

lib/file.ts|1 col 7|
lib/file.ts|3 col 7|

Proposed Fix:

diff --git a/autoload/ale/references.vim b/autoload/ale/references.vim
index c32663fe..ac05a9f2 100644
--- a/autoload/ale/references.vim
+++ b/autoload/ale/references.vim
@@ -22,6 +22,7 @@ function! ale#references#FormatTSResponseItem(response_item, options) abort
         \ 'filename': a:response_item.file,
         \ 'lnum': a:response_item.start.line,
         \ 'col': a:response_item.start.offset,
+        \ 'text': substitute(a:response_item.lineText, '^\s*\(.\{-}\)\s*$', '\1', ''),
         \}
     else
         return {

:ALEInfo

Expand

Current Filetype: typescript
Available Linters: ['cspell', 'deno', 'eslint', 'standard', 'tslint', 'tsserver', 'typecheck', 'xo']
Enabled Linters: ['eslint', 'tsserver']
Ignored Linters: []
Suggested Fixers:
'deno' - Fix TypeScript using deno fmt.
'dprint' - Pluggable and configurable code formatting platform
'eslint' - Apply eslint --fix to a file.
'prettier' - Apply prettier to a file.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
'tslint' - Fix typescript files with tslint --fix.
'xo' - Fix JavaScript/TypeScript files using xo --fix.
Linter Variables:

let g:ale_typescript_tsserver_config_path = ''
let g:ale_typescript_tsserver_executable = 'tsserver'
let g:ale_typescript_tsserver_use_global = 0
Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let b:ale_fixers = ['eslint', 'prettier']
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let b:ale_linters = ['tsserver', 'eslint']
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:

(executable check - success) /Users/bogdan/makabu/ud/website/node_modules/eslint/bin/eslint.js
(finished - exit code 2) ['/bin/zsh', '-c', 'cd ''/Users/bogdan/makabu/ud/website'' && ''/Users/bogdan/makabu/ud/website/node_modules/eslint/bin/eslint.js'' --parser-options=''{project: null}'' --rule=''{''@typescript-eslint/no-floating-promises'': ''off'', ''@typescript-eslint/no-misused-promises'': ''off''}'' -f json --stdin --stdin-filename ''/Users/bogdan/makabu/ud/website/backend/lib/support.ts'' < ''/var/folders/gd/qqwx5zqx1wx1pxq5s72hzkdh0000gn/T/nvimGF564Q/2/support.ts''']

<<>>

(executable check - success) /Users/bogdan/makabu/ud/website/node_modules/.bin/tsserver
(started) ['/bin/zsh', '-c', '''/Users/bogdan/makabu/ud/website/node_modules/.bin/tsserver''']
(finished - exit code 2) ['/bin/zsh', '-c', 'cd ''/Users/bogdan/makabu/ud/website'' && ''/Users/bogdan/makabu/ud/website/node_modules/eslint/bin/eslint.js'' --parser-options=''{project: null}'' --rule=''{''@typescript-eslint/no-floating-promises'': ''off'', ''@typescript-eslint/no-misused-promises'': ''off''}'' -f json --stdin --stdin-filename ''/Users/bogdan/makabu/ud/website/backend/lib/support.ts'' < ''/var/folders/gd/qqwx5zqx1wx1pxq5s72hzkdh0000gn/T/nvimGF564Q/3/support.ts''']

<<>>

@bogdan bogdan added the bug label Feb 27, 2023
@bogdan bogdan changed the title ALEFindReferenced -quickfix doesn't populate matched text ALEFindReferenced -quickfix doesn't populate matched text for tsserver Feb 27, 2023
@w0rp w0rp added enhancement and removed bug labels Mar 8, 2023
@w0rp w0rp changed the title ALEFindReferenced -quickfix doesn't populate matched text for tsserver Add matched text to ALEFindReferences -quickfix for tsserver Mar 8, 2023
@w0rp
Copy link
Member

w0rp commented Mar 8, 2023

Could you add a PR for that, with a test, with a comment explaining what the regex does? (I know what it does, but it's good to explain it to others.) I recommend using get(...) for lineText as I wouldn't be surprised if certain versions of tsserver don't include that key.

@w0rp w0rp self-assigned this Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants