lfilho / cosco.vim Goto Github PK
View Code? Open in Web Editor NEWVIM colon and semicolon insertion bliss
License: MIT License
VIM colon and semicolon insertion bliss
License: MIT License
I generally code using the format:
public function name()
{
something here;
}
When I use this formatting along with the auto add semicolons function it likes to add semicolons to the end of my function declaration like so:
public function name();
{
something here;
}
Is there a way that we could have it check the next line for an opening brace and not add a semicolon if the next line starts with an opening brace?
Question, or an enhancement request:
Just wondering if you may have considered adding "colon" in addition to comma or semicolon (I'm asking with python in mind).
Is that not feasible?
Thanks.
# vim --version
NVIM v0.5.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az242-526
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
Run :checkhealth for more info
here is a working example on my laptop, but when I change trim(str) to s:strip(str), it's not working
" c behaves like so: if it's pre-processing, do nothing
function! filetypes#c#parse()
if trim(b:currentLine) =~ "^#"
let b:wasExtensionExecuted = 1
return
endif
endfunction
Instead of always trying to insert ',' or ';', can you provide a feature of toggling the ',' or ';' on and off at the end of a line?
If I have this
z: Int = 30
And I trigger at the 0, it will insert ;
after the 0. However it will put the cursor between the 3 and 0, and not between the 0 and the ;
If the cursor was before end of the line it works as expected
Neovim v0.9
It is common (in JavaScript, for instance) to have comment block such as the following:
Often used for jsdoc
/**;
* Represents a book.;
* @constructor;
*/;
function Book(title, author) {
}
Ordinary comment block
/*;
* This is a comment.;
*/;
However, Cosco doesn't recognize them as legitimate comment blocks .
My OS: Mac Monterey
My vim configuration:
""
" Plugin: Cosco
" Colon and Semicolon insertion
""
augroup cosco
autocmd FileType javascript,css,json nmap <silent> <Leader>; <Plug>(cosco-commaOrSemiColon)
autocmd FileType javascript,css,json imap <silent> <Leader>; <c-o><Plug>(cosco-commaOrSemiColon)
augroup END
let g:cosco_ignore_comment_lines = 1 " Default : 0
let g:auto_comma_or_semicolon = 1 " Default : 0
" let g:cosco_filetype_whitelist = ['php', 'javascript']
let g:cosco_filetype_blacklist = ['vim', 'bash', 'lua']
Hi, nice plugin.
Can we add ability to pass end symbol to the command as a fallback option? I'm not very much into Vim Script, but maybe we can add mappings like this:
autocmd FileType javascript,css,YOUR_LANG nmap <silent> <Leader>; <Plug>(cosco-commaOrSemiColon)
autocmd FileType javascript,css,YOUR_LANG nmap <silent> <Leader>;; <Plug>(cosco-commaOrSemiColon(";"))
autocmd FileType javascript,css,YOUR_LANG nmap <silent> <Leader>;, <Plug>(cosco-commaOrSemiColon(","))
So, we can press default mapping, see what the plugin did, if the result is incorrect then press ";" or "," to force the plugin to insert or replace the symbol at the end of line.
Opening first Cosco issue on the Halloween 👻
I noticed that when I do a cosco action and undo it, my cursor do not comes back to where it was. Is it possible to ensure it will persist the position?
Hello,
Trying out the auto insertion and so far it was working ok. However, it does break when it tries to modify something that isn't modifiable such as a Unite buffer.
When I have :call cosco#commaOrSemiColon()<CR>
bound to a mapping like <Leader>;
, I might want to repeat that command with .
. For example, I might want to do <Leader>;j.
to add semicolons to two consecutive lines. Currently, the plugin does not support that – .
just repeats the last command I did before calling cosco.
You can use tpope’s repeat.vim to easily add .
support to your plugin as long as the user has repeat.vim installed.
Just discovered this plugin and im really grateful for it.
Quick question, any way to make it work in insert mode?
Hello. Just wanna report this small issue which adds a semicolon on lines even if preceded by a hash #
print "test"; # here's a comment;
# ^ adds a semicolon even if preceded by a #
if ( $whatever ) {;
# ^ same is true for constructs
Thanks for the plugin, just started playing with it. I'm using the auto option, but I noticed that unlike g:cosco_ignore_comment_lines
, and global options in most other plugins, it does not prefix the option with cosco
, making it more likely to conflict with user's other variables and harder to find in vim file. Is that something that makes sense to add?
Hey there. Long time user of this wonderful plugin. After a recent update, I started getting the below error.
Error detected while processing function cosco#commaOrSemiColon[31]..<SNR>194_hasUnactionableLines:
line 2:
E121: Undefined variable: g:cosco_ignore_comment_lines
E15: Invalid expression: (g:cosco_ignore_comment_lines == 1)
NVIM v0.2.1-596-g5a0acd09c
Config file here:
https://github.com/bugeats/dotfiles/blob/master/src/config/nvim/init.vim
Hi Luiz,
I code in C++ so, I'm using cosco.vim to auto insert semicolons. It turns out that when I inserted an include statement, such as #include <iostream>
, then cosco.vim auto inserted the semicolon, which is undesirable.
I believe if you could allow the users to have a variable to ignore some patterns based on regex that'd be great to workaround such minor exceptions. What do you say? I patched the code, viniarck@a845301, and I'm using this variable to ignore C/C++ include statements:
let g:cosco_ignore_pattern="^#"
Let me know if I should open a PR for this or if you have an ideia for a better or more robust approach to ignore patterns. Once again, thanks for cosco.vim, it's really awesome!
I'm not sure why but when coding with php and using the auto add (which works amazingly well) it is adding semicolons to the end of my comments.
Is there something we can add in to check for //
and #
at the beginnings of lines (depending on language)
How one should configure Vim so that cosco.vim automatically adds needed semicolons? I would like to call cosco.vim on previous line whenever I move somewhere in that file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.