Comments (8)
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.
@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.
@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.
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.
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.
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.
@lfilho thanks for the suggestion. It yielded the same result. See image below.
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.
No problem. It's my nature to want to fix things lol 😹.
from cosco.vim.
Related Issues (18)
- When undoing, the cursor do not persist position HOT 3
- Experimental semicolon auto insertion breaks in non-editable buffers HOT 4
- Semicolons are added to comment lines HOT 3
- Semicolons added to methods if braces are opened on the next line HOT 2
- New "Undefined variable" error when invoking on Neovim HOT 5
- print "test"; # here's a comment (adds ; here) HOT 2
- colon support, in addition to comma or semicolon HOT 1
- Missplacing comma with semi-colon HOT 3
- Allow users to ignore semicolon insertion based on a regex pattern HOT 3
- Pass end symbol to the command as a fallback option
- g:auto_comma_or_semicolon needs "cosco" prefix for consistency HOT 1
- Can you provide a 'toggle' feature? HOT 6
- s:strip(string) not working on neovim
- Return to original position is 1 index behind if the action was triggered at the end of the line
- Automatically add needed semicolons HOT 4
- Make the action repeatable with `.` HOT 2
- Possible to use in Insert Mode? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cosco.vim.