-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[feature-request] emit line and column offsets in json output. #991
Comments
I chose not to include the information for several reasons:
|
VimScript is not as powerful as java, it stores strings in This will bring more side effects. and make LanguageTool difficult to use in vim. Counting the col/line number may have issues, but there is one bug in LanguageTool, and someday , it could be fixed. But counting col/line in many different application using LanguageTool may cause many different bugs. Since xml output has line and col fields, what about including line/col in json output and making a caution in documentation ? |
It is really hard to calculate characters in VimScript: LanguageTool takes And calculating line/column number is impossible. Could you please just re-consider it ?? |
If it's buggy, is there any reason we can't fix it in LT? My LanguageTool vim plugin [1] at... My LT does not use vim-8 new asynchronous feature, so |
I still feel this is more a limitation of vim - an editor that cannot deal with character-based position sounds like a missing feature to me. |
Yes, there is a limitation of vim, so, could you please help vim users ?? |
Can't this be fixed in vim? |
I checket the json API at... And even that would still be ambiguous:
Vim has at least the function byteidx({expr}, {nr}) which But I agree with @skywind3000 |
You have to click on the "Model" link to get a more detailed description. I'm not sure about combining characters. I'd assume that invalid UTF-8 causes a Java exception, but I haven't tested it. |
I ran accross the same issue with execute 'go ' . (byteidx(system("cat " . expand('%')), offset) + 1) From there you can get the starting line and column Don't know if the solves the issue but it might help @skywind3000 EDIT: I have an even better solution, not moving the cursor: let l:byte_index = byteidx(system("cat " . expand(myfile)), offset)
let l:line = byte2line(l:byte_index)
let l:col = l:byte_index - line2byte(l:line) |
Just want to say, same here in Emacs. |
Just to keep you updated, this issue is still blocking the vim integration of LanguageTool to work with LanguageTool 6.0 and higher. I don't know the status of this for emacs. |
ale (Asynchronous Lint Engine) is a famous vim 8 dedicated plugin which is used widely after vim8 released.
It uses textlint and write-good for text files linting. and I suppose it is a pity that LanguageTool can't be used in ale.
So, I decided to write ale extension for LanguageTool, the extension must be written in VimScript and will parse the output of LanguageTool.
There are 3 output formats in LanguageTool:
XML is the best which have all the information I want, but parsing XML is too complex in VimScript, or it requires introducing a lot of dependences. The human readable format missed some key elements such as text range (from which column to which column).
Parsing json is much easier in VimScript, vim provides json_decode()/json_encode() functions for VimScript. but when I check the actual json output from LanguageTool, I can't find some key like
fromx
,fromy
,tox
andtoy
in xml format, the json output just have aoffset
field which is counted by characters.Can we have the new fields of
fromx
,fromy
,tox
andtoy
in json output ? If so, it will be much easier to intergrate languagetool in vimscript.As we know, parsing json is much easier in many programming language than parsing XML. Including more information in json format will help LanguageTool integrated with other languages.
Do you think it is a reasonable point to include row and line numbers in json output ?
The text was updated successfully, but these errors were encountered: