Code Monkey home page Code Monkey logo

Comments (8)

lfilho avatar lfilho commented on July 24, 2024 1

Hey Jeff, thanks for reporting this.

I believe I have found the problem. As you can see in the snippet you pasted above, we're expecting a string "comment", but, at least in my setup it's returning "jsComment" (note it's already different than yours above). This was not the case when I first wrote the plugin.

I'm hesitant in adding a jsComment, javaScriptComment to the condition as it would bloat the generic code with something specific to Js...

Can you try fiddling with that match in there, maybe \c*comment would do the trick... I'm on vacation right now so hard for me to test.

PS: Since Javascript is your use case, have you considered using eslint + prettier for taking care of colon/semi-colon for you? That combo works better than my plugin for javascript, plus all the other features they would give you :)

from cosco.vim.

jeffschwartz avatar jeffschwartz commented on July 24, 2024 1

@lfilho thank you for your really rapid response. Greatly appreciated. Though I'm not fluent in vim script I'll gladly take a look and if I can get it to work generically as you suggested then I will issue a pull request. Have a great vacation :)

from cosco.vim.

jeffschwartz avatar jeffschwartz commented on July 24, 2024 1

@lfilho I have filed an issue with Neovim. You can view it here. Your code is correct and would work but synIDattr(synID(line("."),col("."),1) randomly repots an erroneous syntax ID. I am closing out this issue for now but please allow further commenting so that I can report back when the issue is resolved. Thank you for you assistance. Greatly appreciated.

from cosco.vim.

jeffschwartz avatar jeffschwartz commented on July 24, 2024 1

Oh, as for using prettier, well I lean towards plugins that have a narrow focus, though I have to admit I would be totally lost if I wasn't using eslint lol. Have a great day :)

from cosco.vim.

lfilho avatar lfilho commented on July 24, 2024 1

Ahhh sorry! Thanks for doing that!

Will definitely leave it in for comments, don't worry.

I commented in the issue in there, I suspect it had to do with syntax plugins rather than (n)vim itself...

from cosco.vim.

jeffschwartz avatar jeffschwartz commented on July 24, 2024

I am not fluent in vim script but I would guess that the issue might be related to this code:

function! s:hasUnactionableLines()
    " Ignores comment lines, if global option is configured
    if (g:cosco_ignore_comment_lines == 1)
        let l:isComment = synIDattr(synID(line("."),col("."),1),"name") =~ '\ccomment'
        if l:isComment
            return 1
        endif
    endif
   ...

I added the following to my nvim configuration:

nnoremap <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

And the results from running it in both of the comment blocks in my op are:

hi<javaScriptComment> trans<javaScriptComment> lo<Comment>

from cosco.vim.

jeffschwartz avatar jeffschwartz commented on July 24, 2024

@lfilho thanks for the suggestion. It yielded the same result. See image below.

Screen Shot 2022-03-16 at 1 48 56 PM

I also observed it returning an erroneous syntax ID for block comments that didn't have any blank lines, meaning they actually contained text with in the comment block. It happens randomly. Perhaps this is a bug inherited from Vim itself. I don't have vim installed, do you? If you do and you feel like sherlocking you can use the below init file to trigger the report.

nnoremap <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

from cosco.vim.

jeffschwartz avatar jeffschwartz commented on July 24, 2024

No problem. It's my nature to want to fix things lol 😹.

from cosco.vim.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.