Re: Access class member from command line

2024-05-10 Thread Lifepillar
On 2024-05-10, Yegappan Lakshmanan  wrote:
>> Right now, the only issue I have is with autoload scripts in my vimrc,
>> but I see that it's being tracked as #13313 in GitHub. Other than that,
>> I must say that Vim 9 script has been rock solid for me (no more
>> crashes), and very pleasant to use!
>>
>
> I have opened the PR https://github.com/vim/vim/pull/14740 to address
> this issue.

I've just tried that, and it works like a charm! For older versions of
Vim, I've found that I can create a symlink in ~/.vim/autoload, e.g.:

cd ~/.vim/autoload
ln -s ../pack/plugins/foo/autoload/foo.vim

Then foo.vim is found by `import autoload` in my vimrc.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/v1lu3p%24ead%243%40ciao.gmane.io.


Re: Access class member from command line

2024-05-09 Thread Lifepillar
On 2024-05-09, Yegappan Lakshmanan  wrote:
> Hi,
>
> On Wed, May 8, 2024 at 2:11 PM Lifepillar  wrote:
>> > Looks like a bug. Should be able to do `foo.Config.option = true`
>>
>> Indeed. And fixed. That works with the latest Vim (9.1.399).
>>
>
> Yes. This should be addressed by patch 9.1.0398.  If you see any
> additional problems
> in using different types of imported variables in a Vim9 script (after
> this patch), please
> open an issue.  In particular, look for any issues in using nested types.

Right now, the only issue I have is with autoload scripts in my vimrc,
but I see that it's being tracked as #13313 in GitHub. Other than that,
I must say that Vim 9 script has been rock solid for me (no more
crashes), and very pleasant to use!

>> >> But how do I access the class member from the command line? Is that even
>> >> possible?
>>
>> I still haven't found a way to do that, and I'm starting to think that
>> it is not currently possible. If I put this in ~/.vim/autoload/foo.vim:
>>
>
> A class in a Vim9 script is a script-local variable.  So it cannot be
> directly accessed
> from outside the script (without using the script name).

I'm not sure I understand. Classes can be exported, and I'm prepending
the script name, so why doesn't this work in the command line?

:echo foo#C.member

where the script is ~/.vim/autoload/foo.vim, `C` is an exported class
defined in foo.vim, and `member` is a static variable of C. Maybe
because `C` is a type? For comparison, this works in a script:

import autoload 'foo.vim'
echo foo.C.member

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/v1i0o0%24n8%241%40ciao.gmane.io.


Re: Access class member from command line

2024-05-08 Thread Lifepillar
On 2024-05-07, Girish  wrote:
> On Sunday 5 May 2024 at 15:39:53 UTC+2 Lifepillar wrote:

>> Let's say I have this class in some `foo.vim` file:
>>
>> export class Config
>>   public static var option = false
>> endclass
>>
>> Now, I'd like to set `Config.option` to `true` from a script and from
>> the command line. From a script, I can do this:
>>
>> import "foo.vim"
>>
>> type FooConfig = foo.Config
>> FooConfig.option = true
>> echo FooConfig.option # OK
>> echo foo.Config.option # Also works
>>
>> Unfortunately, this gives an error (Undefined variable Config):
>>
>> foo.Config.option = true
>>
> Looks like a bug. Should be able to do `foo.Config.option = true`

Indeed. And fixed. That works with the latest Vim (9.1.399).

>> But how do I access the class member from the command line? Is that even
>> possible?

I still haven't found a way to do that, and I'm starting to think that
it is not currently possible. If I put this in ~/.vim/autoload/foo.vim:

vim9script

export var x = 42

export def F()
enddef

export class C
  public var setting = "ok"
  public static var option = false
endclass

export var config = C.new()

Then these work from the command line:

echo foo#x
call foo#F()
echo foo#config
echo foo#config.setting

But I can't find a way to access the static variable 'option'.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/v1gppm%24jvc%241%40ciao.gmane.io.


Access class member from command line

2024-05-05 Thread Lifepillar
Let's say I have this class in some `foo.vim` file:

export class Config
  public static var option = false
endclass

Now, I'd like to set `Config.option` to `true` from a script and from
the command line. From a script, I can do this:

import `foo.vim`

type FooConfig = foo.Config
FooConfig.option = true
echo FooConfig.option  # OK
echo foo.Config.option # Also works

Unfortunately, this gives an error (Undefined variable Config):

foo.Config.option = true

But how do I access the class member from the command line? Is that even
possible?

Context: I'm exploring alternatives to `g:myplugin_option` to configure
a script without using global variables.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/v1826l%24m0o%241%40ciao.gmane.io.


Re: Nested Classes — thoughts and workarounds

2024-03-23 Thread Lifepillar
On 2024-03-22, Igbanam Ogbuluijah  wrote:
> Hello community,
>
> I've been playing with some idea which has brought me to needing Nested
> Classes in Vim. I am curious what you think about this? Would this be too
> much for Vimscript? If not, what current workarounds would you suggest?

I don't think Vim 9 script needs or would gain anything for such
extensions.

> Context: I'm taking a stab at parsing protobuf definitions into Vim 9
> classes. Nested messages in the protobuf demands
><https://arc.net/l/quote/qfcssecm> nested structs/classes.

Something like:

  message SearchResponse {
message Result {
  string url = 1;
  string title = 2;
  repeated string snippets = 3;
}
repeated Result results = 1;
  }

becomes two classes/structs `SearchResponse` and `SearchResponse_Result`
in the target languages I've looked at. In Vim, you could do the same:

interface Message
endinterface

class SearchResponseResult implements Message
  var url: string
  var title: string
  var snippets: list
endclass

class SearchResponse implements Message
  var results: list
endclass

That seems the most straightforward approach to me.

If you don't care about typing (but wouldn't that defeat the purpose of
protobuf?), you may simply use dictionaries, which can be arbitrarily
nested.

If your problem is parsing, libparser might help:

    https://github.com/lifepillar/vim-devel

Protobuf's grammar seems simple enough. You might even go fancy and
generate parsers from messages, which would be able to parse the
corresponding messages.

I don't see any reason to keep using Vim legacy script for new Vim
scripts.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/utmm5o%2412c1%241%40ciao.gmane.io.


Some comments on :help E1377 (subclassing and constructors)

2024-02-20 Thread Lifepillar
:help E1377 has this paragraph:

Unlike other languages, the constructor of the base class does not
need to be invoked.  In fact, it cannot be invoked.  If some
initialization from the base class also needs to be done in a child
class, put it in an object method and call that method from every
constructor().

That seems accurate, as in the following script `Bar` has its own
(implicitly defined) constructor, and the parent's constructor is not
invoked (no message is printed):

vim9script

class Foo
  var _y = 0

  def new(this._y, z: string)
this.Init(z)
  enddef

  def Init(z: string)
echomsg $'y={this._y}, z={z}'
  enddef
endclass

class Bar extends Foo
endclass

var bar = Bar.new(1) # Sets _y to 1, doesn't print anything

Now, I have a couple of remarks:

It seems a bit counterintuitive that `Bar` cannot be initialized like
`Foo`, but with either `Bar.new()` or `Bar.new(n)`.

It may be the case that `Init()` does something necessary for the
initialization of the object. But `Bar` does not call `Init()`, so `bar`
may be potentially broken.

Ok, all that is as documented and can be remedied, of course:

class Bar extends Foo
  def new(this._y, z: string)
this.Init(z)
enddef
endclass

var bar = Bar.new(1, 'a') # OK

But:

- I have basically redefined the same constructor of the superclass;
- I must know the private members of `Foo` to do that;
- I must be aware that any constructor must call `Init()` for the
  correct initialization of the object. Again, I must know an
  implementation detail of the superclass.

Note that `Foo` may be a library object imported by arbitrary users in
arbitrary scripts.

Wouldn't it make more sense for `Bar` to have the parent's constructor
as a default?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ur2trf%24hf%241%40ciao.gmane.io.


Get list of lambdas and closures

2024-01-31 Thread Lifepillar
Is it possible to get the list of all lambdas? I'm looking for something
similar to :function.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/upecnp%24s9i%241%40ciao.gmane.io.


Re: Building a Reactive Library from Scratch in Vim 9 Script

2023-12-31 Thread Lifepillar
On 2023-12-30, Steve Litt  wrote:
> I had a chuckle when you called Vimscript a "sane language". I'm more
> of a Lua or Python or C guy myself. But looking at your code, it looks
> like the Vim9 script language is a big improvement over that old viml
> stuff.

That was basically the sense of my post. I consider Vim 9 script the
last gift, and one of the most precious ones, Bram left us. My post
expresses my appreciation for the effort of the developers who are
building up on that gift: things are getting really really good! I was
pleasantly surprised that Vim did not crash or misbehave when fed with
some weird snippets such as that Russellian Subscribe() function :)

> Anyway, could you please summarize what you see as the benefits of
> reactive programming?

I can't really speak of the merits (or lack thereof) of reactive
programming. I have just started rewriting the style picker of my
Colortemplate plugin in Vim 9 script. There, the main problem is keeping
the attributes of a highlight group in sync with a bunch of UI widgets,
so it seemed to me like a good chance to explore some alternative
approaches.

>From what I have seen so far, a reactive approach has some potential to
simplify my code both in terms of the amount needed and in terms of
correctness. The devil's in the details, of course, so maybe I will
eventually hit some wall and scratch everything. But I'm learning new
things and having fun, and that's what matters to me at the end of the
day.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/umruq4%247vp%241%40ciao.gmane.io.


Building a Reactive Library from Scratch in Vim 9 Script

2023-12-29 Thread Lifepillar
Today I was entertaining myself with articles about the "reactive
programming" paradigm so popular nowadays, such as this:

https://dev.to/ryansolid/building-a-reactive-library-from-scratch-1i0p

As I could not understand that code, I decided to port it to a sane
language:

https://gist.github.com/lifepillar/d44e6ca33f0b1f66a0b403e133413699

The task was pretty straightforward, I must say. The code still leaves
much to be desired (among the rest because I've tried to deviate from
the original as little as possible), but it works well.

Enjoy!
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/umn1c8%24u80%241%40ciao.gmane.io.


Re: vim9 exported functions not recognized by ctags

2023-12-18 Thread Lifepillar
On 2023-12-16, Nicolas  wrote:
> this is mine .ctags.d
>
> --kinddef-vim=e,export,function,"Vim 9 exported functions"
> --kinddef-vim=f,function,"Vim 9 non-exported functions"
> --kinddef-vim=g,global,"Vim 9 global variables"
> --kinddef-vim=K,const,Vim 9 constants
> --regex-vim=/^\s*export\s+def\s+([^(:]+)/\1/e,export,def/
> --regex-vim=/^\s*def\s+([^(]+)/\1/f,function,def/
> --regex-vim=/^\s*(g:\w+)\b/\1/g,global/
> --regex-vim=/^(\s*export\s+)?const\s+(\w+)/\2/K,const/
> --regex-vim=/^(\s*export\s+)?final\s+(\w+)/\2/K,const/
>
> with g:tagbar_type_vim = {'ctagstype': 'vim', 'kinds': ['e:export',
> 'g:global', 'K:const', 'f:function']}
>
> Hope this helps.
> nicolas

That should work, shouldn't it? Or what is your issue with it?

My current vim.ctags looks like this:

--kinddef-vim=g,vim9global,Vim 9 global variables
--kinddef-vim=K,vim9const,Vim 9 constants
--kinddef-vim=L,vim9class,Vim 9 class
--kinddef-vim=I,vim9interface,Vim 9 interface
--regex-vim=/^export\s+def\s+([^(]+)/\1/f/
--regex-vim=/^\s*(g:\w+)\b/\1/g,vim9global/
--regex-vim=/^(export\s+)?(const|final)\s+(\w+)/\3/K,vim9const/
--regex-vim=/^\s*(export\s+)?(abstract\s+)?class\s+(\w+)/\3/L,vim9class/
--regex-vim=/^\s*(export\s+)?interface\s+(\w+)/\2/I,vim9interface/

That works with Universal Ctags 6.0.0, as confirmed by:

uctags --list-kinds=Vim

which outputs:

a  autocommand groups
c  user-defined commands
f  function definitions
m  maps
v  variable definitions
n  vimball filename
C  constant definitions
g  Vim 9 global variables
K  Vim 9 constants
L  Vim 9 class
I  Vim 9 interface

In my `vimrc` I set the path to the executable:

g:tagbar_ctags_bin = '/opt/local/bin/uctags'

and for Vim tags:

g:tagbar_type_vim = {
  'kinds': [
'L:classes',
'f:functions and methods',
'v:variables:1:0',
'g:global variables',
'K:constants',
'c:commands:0:0',
'a:autocommand groups:1',
'm:maps:1:0',
],
  }

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ulqjdr%2416cs%241%40ciao.gmane.io.


Re: Out_cb callback handler in vim9

2023-12-10 Thread Lifepillar
On 2023-12-09, Nicolas  wrote:
> Hi all,
>
> According to Bram example in the job's help now,
> Is it possible to pass additional parameters to job's handlers callback in
> vim9script ?

Yes. See, for instance, $VIMRUNTIME/autoload/typeset.vim, in particular
the Callbacks section and the Typeset() function.

> This minimal example with additional params:
> def Compress_OnExit(job_id: job, exit_status: number, foo: string): void
> echom 'Job OnExit ' .. job_id->string() .. ' exited with status ' ..
> exit_status
> # Compress_CopyToDrive('PATRIOT')
> enddef
> var job = job_start(cmd, { 'exit_cb': function('Compress_OnExit',
> ['foo']) } )

That should be:

var job = job_start(['ls'], {
  exit_cb: (j, e) => Compress_OnExit(j, e, 'foo')
})

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ul553q%24puu%241%40ciao.gmane.io.


Re: Rely on ‘runtimeparh’ in import autoload

2023-11-25 Thread Lifepillar
On 2023-11-24, Matan Nassau  wrote:
> When is it good practice to use the import autoload form that relies
> on ‘runtimepath’?
>
> import autoload ‘foo.vim’
>
> I think plugins generally know where their autoload stuff is, and can
> gain a few milliseconds by pointing the import directly at it with
> a relative path.
>
> And, the runtimepath form generally won't work when ‘loadplugins’
> isn’t set (when starting Vim with --clean for example).

What is the use case for an autoload mechanism when plugins have been
turned off? Are you talking about `import autoload` statements in
a vimrc file?

> So what is the feature for

Vim 9 script inherits the autoload mechanism from Vim legacy script,
where runtimepath is used. I think that is the main reason for that
behaviour.

>, when is it a good time to use it?

It's just a matter of personal preference. In most cases the difference
won't be noticeable. I'd stick with relative paths to avoid potential,
although probably rare, name conflicts.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ujssak%24157a%241%40ciao.gmane.io.


Re: Location list entries for unsaved buffer open a new buffer

2023-10-21 Thread Lifepillar
On 2023-10-21, Yegappan Lakshmanan  wrote:
> On Sat, Oct 21, 2023 at 7:09 AM Lifepillar  wrote:
>> How do I generate location list entries that refer to the proper unsaved
>> buffer?
>>
>>
> There is a item in the  todo list for more than 20 years now for this:
>
> -   Add %b to 'errorformat': buffer number. (Yegappan Lakshmanan / Suresh
> Govindachar)

:-) I have found the following workaround: I pass the buffer number to
the callback, then I iterate over each parsed line and manually set the
buffer:

def Callback(channel: channel, msg: string, bufnr: number, ...)
  [...]
  var what = getqflist({"lines": [msg], "efm": efm})

  for item in what.items
item["bufnr"] = bufnr
  endfor

  setloclist(winid, what.items, "a")
enddef

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/uh10ir%24u9l%241%40ciao.gmane.io.


Location list entries for unsaved buffer open a new buffer

2023-10-21 Thread Lifepillar
I have a function that pipes a buffer into an external program, then
parses its output in a callback and adds the parsed results to
a location list. Simplified code for the callback:

def Callback(channel: job, msg: string, winid: number, efm: string, cwd: 
string)
  silent execute "lcd" cwd
  var what = getqflist({"lines": [msg], "efm": efm})
  silent lcd -
  setloclist(winid, what.items, "a")
enddef

The lines to be parsed have a pretty standard format:

filename:line:col message

The program reads from stdin, hence `filename` is passed as an argument
to the program. The program simply puts whatever filename it gets into
its output messages.

This works fine for buffers backed up by a file: I pass the buffer's
name as the filename argument. My problem is that I don't know how to
create an entry in the location list for an unsaved buffer. Passing
something like '[No Name]', 'unnamed', or similar does not work. The
location list ends up having entries that look like this:

unnamed|1 col 8 E123| some message

If the unsaved buffer ia buffer 1, then the message above is parsed as:

{'items': [{'bufnr': 2, 'lnum': 1, 'col': 8, 'text': 'some message', ...}]}

Therefore, selecting such entries causes a new buffer 2 to be created.

How do I generate location list entries that refer to the proper unsaved
buffer?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/uh0m28%244lk%241%40ciao.gmane.io.


Re: Edit edit tar.gz file

2023-10-21 Thread Lifepillar
On 2023-10-21, Nutcha Schonn  wrote:
> About 3-4 years ago I remember that I could edit a edit tar.gz file with vi
> command.
> When trying that today it does not work, is there something I can do to get
> it to work with the latest VIM 9 version?

It works with Vim 9.0.1946. Besides:

:echo g:loaded_tarPlugin

prints `v32`.

Either your runtime does not have the plugin (try `:e
$VIMRUNTIME/plugin/tarPLugin.vim`), or your configuration is preventing
the plugin from loading (for instance, if you set g:loaded_tarPlugin=1
in your vimrc).

You mention vi rather than vim: that may make a difference.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/uh0k1d%2416j5%241%40ciao.gmane.io.


Re: Licensing question: compatibility between Vim license and GPL

2023-10-17 Thread Lifepillar
On 2023-10-16, Christian Brabandt  wrote:
>
> On So, 15 Okt 2023, Tony Mechelynck wrote:
>
>> On Sun, Oct 15, 2023 at 7:29 PM Lifepillar  wrote:
>> >
>> > Can code released under Vim license include third-party code released
>> > under GPLv2 or GPLv3?
>> >
>> > I have read that Vim license is "GPL-compatible", but it is not clear to
>> > me which way such compatibility works.
>> >
>> > Thanks for providing legal advice for free ;)
>> > Life
>>
>> I am not a lawyer, nor do I play one on TV; but I believe that the
>> following (at the bottom of the ":help license" text) is relevant:
>>
>> - According to Richard Stallman the Vim license is GNU GPL compatible.
>>   A few minor changes have been made since he checked it, but that should not
>>   make a difference.
>>
>> - If you link Vim with a library that goes under the GNU GPL, this limits
>>   further distribution to the GNU GPL.  Also when you didn't actually change
>>   anything in Vim.
>>
>> - Once a change is included that goes under the GNU GPL, this forces all
>>   further changes to also be made under the GNU GPL or a compatible license.
>>
>> - If you distribute a modified version of Vim, you can include your name and
>>   contact information with the "--with-modified-by" configure argument or the
>>   MODIFIED_BY define.
>
> Thanks, that is also my understanding of the compatibility of the
> licenses.

Thanks, that's useful.

This licensing stuff has higher complexity than the halting problem.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ugmu2c%24g7p%241%40ciao.gmane.io.


Re: typewriter sounds

2023-10-17 Thread Lifepillar
On 2023-10-17, rwmit...@gmail.com  wrote:
> Lifepillar,
>
> Could you include a sample g:keysound configuration that makes use of the
> auxiliary typewriter-sounds ?  It would be nice to start from a known
> interesting setup.
>
> ( the help file mentions using keyN.mp3 where all of the auxiliary sounds
> are keyNNN.mp3; yes, that is an easy conversion to make, but it just feels
> out of sync starting with different names)

I have added an example to lifepillar/vim-keysound's Readme.

As this is a question about a plugin, using GitHub or contacting me via
email is preferable to using Vim's mailing list.

Enjoy,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ugmt2a%241682%241%40ciao.gmane.io.


Licensing question: compatibility between Vim license and GPL

2023-10-15 Thread Lifepillar
Can code released under Vim license include third-party code released
under GPLv2 or GPLv3?

I have read that Vim license is "GPL-compatible", but it is not clear to
me which way such compatibility works.

Thanks for providing legal advice for free ;)
Life

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ugh7h1%24g46%241%40ciao.gmane.io.


Re: Is uploading new scripts to vim.org possible?

2023-10-15 Thread Lifepillar
On 2023-10-15, Christian Brabandt  wrote:
>
> On Sa, 14 Okt 2023, Lifepillar wrote:
>
>> Now, after pressing "upload" I'm sent back to the form page, but the
>> script is still not uploaded.
>
> I tried it yesterday and it worked. I now tried it again and it still
> works.
>
> Let's take this off-list. Can we connect around 14:00 EST so I can watch
> the log files while you are trying to do it?

Sorry, I had to go. Anyway, I've found that the problem is the upload
size limit, which my file, weighing at >500KB, exceeds. Somehow,
yesterday I've missed the "Request Entity Too Large" error at the top of
the page.

Removing some assets from the plugin has made the upload go through.

I will consider a different way of distributing the assets: in fact,
I don't like such large plugins myself.

Thanks for your support!
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/uggarg%24q73%241%40ciao.gmane.io.


Re: Is uploading new scripts to vim.org possible?

2023-10-14 Thread Lifepillar
On 2023-10-14, Christian Brabandt  wrote:
>
> On Sa, 14 Okt 2023, Lifepillar wrote:
>
>> On 2023-10-14, Christian Brabandt  wrote:
>> >
>> > On Sa, 14 Okt 2023, Lifepillar wrote:
>> >
>> >> I am not able to upload new scripts to www.vim.org. The "type" drop-down
>> >> is empty and there is no "upload/submit" button or similar. Is that
>> >> intentional?
>> >
>> > of course not :) Sorry should be fixed now.
>>
>> Thanks, the page now look fine, but after pressing "upload",
>> add_script.php send me to an empty page and the plugin is not uploaded.
>
> Ah okay, I did not try to upload a new script. This also should work
> now.

Now, after pressing "upload" I'm sent back to the form page, but the
script is still not uploaded.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ugf4ib%24lc4%241%40ciao.gmane.io.


Re: Is uploading new scripts to vim.org possible?

2023-10-14 Thread Lifepillar
On 2023-10-14, Christian Brabandt  wrote:
>
> On Sa, 14 Okt 2023, Lifepillar wrote:
>
>> I am not able to upload new scripts to www.vim.org. The "type" drop-down
>> is empty and there is no "upload/submit" button or similar. Is that
>> intentional?
>
> of course not :) Sorry should be fixed now.

Thanks, the page now look fine, but after pressing "upload",
add_script.php send me to an empty page and the plugin is not uploaded.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ugegot%24mko%241%40ciao.gmane.io.


Is uploading new scripts to vim.org possible?

2023-10-14 Thread Lifepillar
I am not able to upload new scripts to www.vim.org. The "type" drop-down
is empty and there is no "upload/submit" button or similar. Is that
intentional?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/uge98v%24tvs%241%40ciao.gmane.io.


Re: E325 ATTENTION message wrapping/formatting problem

2023-09-30 Thread Lifepillar
On 2023-09-29, 'Trey Blancher' via vim_use  wrote:
> I have a problem with the E325 ATTENTION message, informing me of an
> existing swap file.  It appears that every line in the message is
> inordinately long,
> [...]
> This has been going on for quite some time, I don't know exactly when it
> started.  Is there any way to fix this?

I don't know, but you may mitigate the problem with `SwapExists` to call
a function that uses a less intrusive prompt.

For example, vimrc includes:

vim9script
import autoload "my/libvimrc.vim" as lib
set cmdheight=2
autocmd SwapExists * lib.SwapExists()

Then, in libvimrc.vim, I define:

export def SwapExists()
  echohl WarningMsg
  echon $'A swap file exists: {fnamemodify(v:swapname, ":t")}'
  echohl None
  echon "\n" .. 'read-(o)nly (e)dit (r)ecover (d)elete (q)uit (a)bort 
(ENTER for details) '
  v:swapchoice = nr2char(getchar())
  echo "\r"
enddef

The same can be done in legacy Vim script, of course.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ufa2i1%24usi%241%40ciao.gmane.io.


Re: Vim9 script performance vs. legacy

2023-08-31 Thread Lifepillar
On 2023-08-31, Salman Halim  wrote:
> On Wed, Aug 30, 2023 at 5:25 PM Lifepillar  wrote:
>> For a more apples-to-apples comparison, below is the execution time of
>> `libcolor.Neighbours()` from my libcolor library,³ which is a literal
>> translation of a legacy colortemplate#colorspace#k_neighbours() from
>> Colortemplate v2:
>>
>>  k | Legacy Vim script | Vim 9 script
>> ---|---|-
>>  1 |  73.8 ms  |5.1 ms
>> 10 | 648.4 ms  |   42.9 ms
>> 20 |1164.1 ms  |   97.7 ms
>>
>> The advantage of Vim 9 script is very significant. The benchmarking code
>> is at the end of this message for reference.
>>
>
> This is between 11 to 15+ times faster. Interestingly, running it 20 times
> reduced the advantage slightly. Just an anomaly where the CPU started doing
> something else, d'you suppose?

That k is an argument of the function (the function finds the k colors
that are most similar to a given color). Each reported figure is an
average of ten executions. I have not reported (and not computed)
confidence intervals, so 11–15x may just be within noise limits.

Interestingly, I ran those benchmarks on a version of Vim compiled by
myself. If I use my system's Vim I get better results:

 k | Legacy Vim script | Vim 9 script
---|---|-
 1 |  33.1 ms  |4.0 ms
10 | 283.9 ms  |   20.7 ms
20 | 512.8 ms  |   51.0 ms

The gap narrows a bit: Vim 9 script is 8–10x faster. Still quite a lot.

Now, I have to find out how to optimize my custom build...

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ucqo6c%248i9%241%40ciao.gmane.io.


Re: Vim9 script performance vs. legacy

2023-08-30 Thread Lifepillar
On 2023-08-29, Salman Halim  wrote:
> Hello,
>
> I've been writing my scripts using Vim 9 recently (though without classes)
> and was wondering if anybody had any performance metrics/benchmarks they
> would be willing to share that compare Vim 9's speed compared to the same
> thing written in legacy code.

I have rewritten Colortemplate v3¹, which is a somewhat complex project,
in Vim 9 script. This is how long it takes to build some sets of color
schemes on my laptop:

Template | Legacy Vim | Vim 9 script

Gruvbox 8| 17.2s  |   3.7s
Solarized 8  | 17.4s  |   2.2s
Vim colorschemes²| 20.5s  |   3.2s

¹ https://github.com/lifepillar/vim-colortemplate
² https://github.com/vim/colorschemes

And this comparison is a bit apples vs oranges because it was not
a porting, but a complete rewrite. For instance, instead of an hoc
top-down recursive-descent parser, I am now using a parser combinators
library in functional style³—something that would be cumbersome to write
in legacy Vim script, and it would most likely perform horribly.
Functions calls are much more efficient in Vim 9 script.

For a more apples-to-apples comparison, below is the execution time of
`libcolor.Neighbours()` from my libcolor library,³ which is a literal
translation of a legacy colortemplate#colorspace#k_neighbours() from
Colortemplate v2:

 k | Legacy Vim script | Vim 9 script
---|---|-
 1 |  73.8 ms  |5.1 ms
10 | 648.4 ms  |   42.9 ms
20 |1164.1 ms  |   97.7 ms

The advantage of Vim 9 script is very significant. The benchmarking code
is at the end of this message for reference.

³ https://github.com/lifepillar/vim-devel

> I find that a significant amount of my script-writing time is used in
> calling functions such as matchlist, popup_create and the such, which seem
> to me to be identical (unless you tell me that Vim 9 has access to more
> optimised version of these).

I believe that built-in functions and commands should mostly show
similar performance.

> Maybe the 'for' loop where I iterate over a list of strings is faster in
> Vim 9 because it's both compiled and statically typed?

Likely so. Not an answer to your question, but you may take a look at
some Vim 9 script benchmarks here:

https://github.com/lacygoill/wiki/blob/main/vim/vim9.md

in the "What's the fastest between" section, and maybe compare with
similar loops in legacy Vim script.

> One of the things that caught me recently was that popup_create takes a
> parameter called 'line' which can be either a number or the word 'cursor'.
> It cannot be the STRING '2', it has to be the NUMBER 2 while 'cursor' is a
> string. In legacy script, no problem. Here, I had to make it a string
> variable and then see do something like 'lineNumber != "cursor" ?
> str2nr(lineNumber) : lineNumber' to convert it to a number if needed. i'm
> trying to figure out whether there is a measurable speed advantage to going
> through these motions or if I should just write my scripts in legacy Vim
> script.

>From my experience on porting scripts to the new syntax, the stricter
typing rules help finding bugs and write cleaner code. It is a win,
regardless of speed.

But Vim 9 script also has to coexist with the ecosystem of Vim
functions, and in some cases there is some unavoidable friction, as in
your example. For your specific example, I'd probably wrap the annoying
conversion into a function (did I say that function calls are cheap?):

def PopupLine(lineNumber: string): any
  if lineNumber == 'cursor'
return lineNumber
  endif
  return str2nr(lineNumber)
enddef

Btw, differently from legacy script, an `if` command is not slower than
using `?`: both constructs gets compiled into the same bytecode.

> What do people use for their own stuff these days?

Only Vim 9 script. Bram gave us a wonderful gift, and I am very glad to
see that other developers are actively maintaining it and refining it.

Happy Vim scripting!
Life.

---
vim9script

# Benchmarking a naive k-neighbors algorithm
# in legacy Vim script vs Vim 9 script

import 'libcolor.vim' as libcolor

def Benchmark(Fn: func, args: list = [], repeat = 1): float
  var i = 0
  const start = reltime()

  while i < repeat
call(Fn, args)
++i
  endwhile

  return 1000 * reltime(start)->reltimefloat() / repeat
enddef

const n_repeat = 10

for k in [1, 10, 20]
  # Vim 9 script
  echomsg Benchmark(libcolor.Neighbours, ['#f54f29', k], n_repeat) "ms"

  # Legacy Vim script
  echomsg Benchmark(
colortemplate#colorspace#k_neighbours, ['#f54f29', k], n_repeat
  ) "ms"
endfor


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text

Re: [vim9script] How to compare two objects for identity vs equality?

2023-07-23 Thread Lifepillar
On 2023-07-23, Lifepillar  wrote:
> Fine, == is value-based equality. Is there a way to compare for
> identity, that is, so that o1 and o2 are considered two different
> instances?

Aaah, never mind, there are `is` and `isnot`. Time to find a cool place
to avoid brain melting, I guess...

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u9jrjc%24ivt%241%40ciao.gmane.io.


[vim9script] How to compare two objects for identity vs equality?

2023-07-23 Thread Lifepillar
The following test passes:

```vim
vim9script

class C
endclass

def Test_ObjectEquality()
  var o1 = C.new()
  var o2 = C.new()

  assert_true(o1 == o2)
enddef

v:errors = []
Test_ObjectEquality()
echo v:errors
```

Fine, == is value-based equality. Is there a way to compare for
identity, that is, so that o1 and o2 are considered two different
instances?

Thanks,
Life.



-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u9jr7p%2425h%241%40ciao.gmane.io.


Re: [vim9script] On extending interfaces

2023-07-20 Thread Lifepillar
> Also, if a concrete class has to implement both i1 and i2 explicitly,
> then i2 might as well not subclass i1.

Right, that's the approach I am currently adopting, which is fine
because my interfaces are small.

I may add that the problem with an orthogonal approach such as this:

interface I1
   def Foo()
endinterface

interface I2
   def Bar()
endinterface

class C implements I1, I2
  ...
endclass

class D implements I1, I2
  ...
endclass

is that there is no type for "C or D" or, more generally, for something
that "implements both I1 and I2", e.g.:

def F(X: ???)
  X.Foo()
  X.Bar()
enddef

where ??? = "anything implementing both I1 and I2". So, my current best
approximation is:

interface I1
  def Foo()
endinterface

interface I2  # (Virtually) extends I1
  def Foo()
  def Bar()
endinterface

class C implements I1, I2
  ...
endclass

class D implements I1, I2
  ...
endclass

def F(X: I2)
  X.Foo()
  X.Bar()

def G(Y: I1)
  Y.Foo()

which is perfectly fine (both F() and G() will accept objects of class
C or D), although the repetition in I2 may become a tad inconvenient if
I1 is large. Hence, my proposal.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u9b156%24bjn%241%40ciao.gmane.io.


[vim9script] On extending interfaces

2023-07-19 Thread Lifepillar
Vim 9 script allows the following definitions, in which I2 extends I1 by
"implementing" it:

interface I1
  def Foo()
endinterface

interface I2 implements I1
  def Foo()
  def Bar()
endinterface

The above compiles: I don't know whether it is intentional, but it is
pretty cool! Or, it would be if the following code worked:

def Echo(obj: I1)
  obj.Foo()
enddef

class C2 implements I2
  def Foo()
echo 'C2'
  enddef

  def Bar()
  enddef
endclass

const c2 = C2.new()
Echo(c2)  # ERROR

This results in:

type mismatch, expected object but got object

But C2 does conform to I1! To fix the error, it is necessary to declare
all the interfaces implemented by C2, that is:

class C2 implements I1, I2
  # etc.

I will mention two other minor issues:

- I2 must declare Foo() again: it would be nice if that definition could
  be inferred.
- "implements" is not a very accurate description: "extends" would make
  more sense, intuitively.

In summary, what I am asking is whether Vim could (or should) support
this syntax:

interface I1
  def Foo()
endinterface

interface I2 extends I1
  def Bar()
endinterface

with the following implications:

1. any class implementing I2 must implement both Foo() and Bar().
2. any object of a class implementing I2 may be used wherever an object
   with type I1 is expected.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u990to%24rvl%241%40ciao.gmane.io.


Re: Improving vim startuptime

2023-07-16 Thread Lifepillar
On 2023-07-16, Manas  wrote:
> `startuptime` surprisingly shows me a mere 656ms, while hyperfine shows
> me 2.7s. I am not sure how this discrepancy is arising. Here is the full
> log. https://pastebin.mozilla.org/uTrJ7i8N
>
> I see 234ms (out of those 656ms, ~35%) due to VimEnter autocommands.

170ms are also spent loading buffers. Do you need those to be loaded
eagerly at startup? Also, is context.vim for ConTeXt? ConTeXt support is
built-in into Vim (`:help ft-context`): do you need a plugin for that?
If so, why loading it at startup?

In general, if you see `autoload` paths in the output of --startuptime,
you should look further, because those are likely files that do not need
to be loaded at once.

You may shave some time off by avoiding loading built-in plugins that
you know you'll never use. In my vimrc, I disable some of those as
follows:

  let g:loaded_getscriptPlugin = 1
  let g:loaded_gzip = 1
  let g:loaded_logiPat = 1
  let g:loaded_rrhelper = 1
  let g:loaded_tarPlugin = 1
  let g:loaded_vimballPlugin = 1
  let g:loaded_zipPlugin = 1

But your startup time is relatively high (mine is <60ms, an order of
magnitude less than yours, but still three times more than `vim
--clean`!), so I'd first act on the slowest parts. Certainly, you should
(and likely could) try to bring the number of autocommands close to
zero.

> My autocommands are just scattered throughout vimrc. Most of them are
> like:
>
> au FileType  [mappings|calls]
>
> Maybe there is a way to organize them better?

Put filetype-specific stuff under

~/.vim/after/

For instance, these are a few things you may put in
~/.vim/after/ftplugin/tex.vim for (La)TeX files:

" Local settings
setlocal conceallevel=0

" Filetype-specific mappings
nnoremap  tp :update:PdfLaTeX

" Filetype-specific commands
command! -buffer -nargs=? -complete=file PdfLaTeX  call 
local#tex#typeset()

Anything that does not need to be immediately available when the
filetype is set goes into a corresponding autoload file. In the example
above, the typeset() function is needed only when the user executes
:PdfLateX. That function is then defined in a separate
~/.vim/autoload/local/tex.vim (I put my own stuff under a `local`
directory, but that's just my convention: any tree structure under
`autoload` will do).

Btw, this example is in legacy Vim script, but if you are starting
afresh I'd recommend using the new Vim 9 script syntax. See `:help
vim9`.

The same concept applies to your vimrc: anything that does not need to
be set at once when Vim starts should be turned into an autoload
function.

> And there are a ton of plugins too. Is there any way to only source them
> conditionally?

Yes. Put them under ~/.vim/pack/SOMEDIR/opt, where SOMEDIR is a name of
your choice. Then, use `packadd` to load them when necessary, either
manually or automatically. For instance, this is my Tagbar configuration
in my vimrc:

let g:tagbar_ctags_bin = '/opt/local/bin/uctags'
nnoremap  vt :silent call local#tagbar#toggle()

Then, the function that lazily loads the plugin and toggles the tag bar
is in ~/.vim/autoload/local/tagbar.vim:

fun! local#tagbar#toggle()
  if !exists("g:loaded_tagbar")
packadd tagbar
  endif
  TagbarToggle
endf

You are using a plugin manager: I would also check whether the plugin
manager has a way to defer loading plugins.

> I can also try removing some of the old plugins. I haven't done a
> cleanup in a while.

That's a very good idea: as you become more comfortable with Vim, you
should review your plugins and get rid those that you are able to
replace with your own code (if you are willing to spend time on writing
your own stuff, of course) or with Vim built-in functionality.

For each plugin, ask you yourself:

- do I really need this? Maybe Vim already provides >90% of what the
  plugin does, and I just need to learn Vim a bit better. I may live
  without the remaining <10%, write my own code to fill the gap, or find
  another plugin that covers just that 10%. Sites like
  https://vim.fandom.com/wiki/Vim_Tips_Wiki may be helpful.
- Am I fully making use of this plugin? Sometimes, a plugin has
  a hundred features, but I am using two or three. Maybe, I can
  implement those two or three features myself?
- Is there an equivalent plugin that's less complex and possibly faster?
  Fortunately, the Vim plugin ecosystem is vast. And the less popular
  alternative is often as good or better than "what people is using".

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Re: vim9 Equivalence of __FILE__, __LINE__, and __FUNCTION__ usage in C++

2023-07-04 Thread Lifepillar
On 2023-07-04, Nicolas  wrote:
> Hi Life,
>
> My Main goal is to add prefix of vim9script current '__FUNCTION__' to my
> debug message.

Something along these lines, perhaps?

vim9script

def Debug(F: func)
  echo string(F)
enddef

def Foo()
  Debug(Foo)
enddef

def Bar()
  Foo()
  Debug(Bar)
enddef

Bar()

I don't think Vim 9 script has the kind of introspection you are asking
for.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u820gq%245pn%242%40ciao.gmane.io.


Re: vim9 Equivalence of __FILE__, __LINE__, and __FUNCTION__ usage in C++

2023-07-04 Thread Lifepillar
On 2023-07-04, Nicolas  wrote:
> Hi,
>
> Is there an equivalence in vim9 of  __FILE__, __LINE__, and __FUNCTION__
> usage in C++
>

The closest to __FILE__ is likely  (`:help `). I use this
snippet to get the path of the current script:

const PATH = resolve(expand(':p'))

Or to source a file in the same directory as the current script:

source :h/some_other_script.vim

For __LINE__ and __FUNCTION__, I don't know what "equivalent"
alternative to suggest, but if you elaborate on what your goal is, it
will be easier to help.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u81ucu%2410nc%241%40ciao.gmane.io.


Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Lifepillar  wrote:
>> Yes, in Vim9 script the index is in characters.  In legacy script it is
>> in bytes.
>>
>> The help for this doesn't have it's own tag, I'll add one.
>> You can find it above ":help vim9-gotchas".
>
> I was expecting to find it under `:help vim9-differences`, but either
> I missed the relevant item, or it's not there, in which case it could be
> added there.

Sorry, I read too fast. Maybe, a reference "see also vim9-gotchas" might
be added under vim9-differences, which seems to me the obvious place to
go (and probably easier to search than "gotchas").

Btw, despite the change having caused me some headache debugging one of
my scripts, I think that it makes a lot of sense for a text editor
scripting language to index strings by characters, so I welcome the
change!

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u5f888%24151t%243%40ciao.gmane.io.


Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Bram Moolenaar  wrote:
>
>> Legacy Vim script:
>>
>> let text = 'àbc'
>> echo text[2]
>>
>> Result: 'b'
>>
>> Vim 9 script:
>>
>> const text = 'àbc'
>> echo text[2]
>>
>> Result: 'c'
>>
>> Is the different behavior (counting chars vs bytes?) intentional?
>
> Yes, in Vim9 script the index is in characters.  In legacy script it is
> in bytes.
>
> The help for this doesn't have it's own tag, I'll add one.
> You can find it above ":help vim9-gotchas".

I was expecting to find it under `:help vim9-differences`, but either
I missed the relevant item, or it's not there, in which case it could be
added there.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u5f7o1%24151t%241%40ciao.gmane.io.


Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Lifepillar  wrote:
> On 2023-06-03, Lifepillar  wrote:

> Mmh, even strpart(), which is supposed to count bytes, gives the same
> result:

Forget this: strpart() is fine. I have trouble just with indexing.

Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u5f56r%24q6q%242%40ciao.gmane.io.


Re: [vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
On 2023-06-03, Lifepillar  wrote:
> Legacy Vim script:
>
> let text = 'àbc'
> echo text[2]
>
> Result: 'b'
>
> Vim 9 script:
>
> const text = 'àbc'
> echo text[2]
>
> Result: 'c'
>
> Is the different behavior (counting chars vs bytes?) intentional?

Mmh, even strpart(), which is supposed to count bytes, gives the same
result:

echo strpart(text, 2, 1)

is 'b' in legacy Vim, but 'c' in Vim 9 script.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u5f4fs%24q6q%241%40ciao.gmane.io.


[vim 9 script] String indexing behavior different from legacy Vim

2023-06-03 Thread Lifepillar
Legacy Vim script:

let text = 'àbc'
echo text[2]

Result: 'b'

Vim 9 script:

const text = 'àbc'
echo text[2]

Result: 'c'

Is the different behavior (counting chars vs bytes?) intentional?

Thanks,
Life.



-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u5f43j%2417tv%243%40ciao.gmane.io.


Re: The package you uploaded (vim-noweb.tgz) is empty

2023-06-03 Thread Lifepillar
On 2023-06-02, Bram Moolenaar  wrote:

> You could try using another browser.

I have tried with Safari, Brave, and LibreWolf (~Firefox) on macOS to no
avail. I have taken care to disable ad blockers and, afaics, only
cross-site cookies are blocked.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u5f3vd%2417tv%242%40ciao.gmane.io.


Re: The package you uploaded (vim-noweb.tgz) is empty

2023-06-02 Thread Lifepillar
On 2023-05-26, Edward McGuire  wrote:
> I offered a tarball containing an ftdetect, a syntax, and a README and
> LICENSE.
> The site replied: "The package you uploaded (vim-noweb.tgz) is empty".

I am getting the same error, e.g.:

vim-solarized8-1.5.0.tar.gz is empty, are you sure you specified the 
correct path?

I have tried to upload both a .tar.gz and a .zip file: no difference.

Script IDs I've tried: 5575 (WWDC17 colorscheme) and 5388 (Solarized 8).

URLs:
https://www.vim.org/scripts/script.php?script_id=5575
https://www.vim.org/scripts/add_script_version.php?script_id=5388

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/u5ck21%248ar%242%40ciao.gmane.io.


Re: [vim9script] Forward declarations for classes?

2023-03-26 Thread Lifepillar
On 2023-03-26, Bram Moolenaar  wrote:
> The second one should just work.  Currently the class is only defined
> when "endclass" is found.  Doing it earlier is more implementation work,
> but it should not require anything on the user side.
>
> For the first example I'm not sure what the best solution is.  There is
> a plan to add some kind of typedef, but it would still require something
> extra to indicate the actual implementation will follow later.

Typedefs would look super nice to me, but for another reason: type
aliasing would make my code a lot easier to read!

> There is trouble when it's not just the class name that needs to be
> known, but also what it contains.  Then a forward declaration quickly
> becomes a lot of duplicate text.  And recursive dependencies need to be
> handled, which is also relevant in this example.

Thanks for the thorough reply. This is not a blocker, at least for the
code I write, as `any` is a sufficiently good workaround, which perhaps
requires some extra care with typing in some cases, but nothing
dramatic. Looking forward to seeing these last issues being ironed out!

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tvqfk5%245j9%241%40ciao.gmane.io.


[vim9script] Forward declarations for classes?

2023-03-26 Thread Lifepillar
Consider the following example:

class Rgb
  this.r: float
  this.g: float
  this.b: float

  def ToHsv(): Hsv
# ...
  enddef
endclass

class Hsv
  this.h: float
  this.s: float
  this.v: float

  def ToRgb(): Rgb
# ...
  enddef
endclass

In a scenario like the above, the return type of ToHsv() must be changed
to `any`. Is a mechanism to make the above code legal being considered?

Of a similar flavour:

class X
  def Clone(): X
# Return a copy of this
  enddef
endclass

Currently, Clone() must be typed as `any`.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tvp84d%24iro%241%40ciao.gmane.io.


[vim9script] Default value for object argument?

2023-03-12 Thread Lifepillar
How do you define a default value for a function argument whose type is
a class? I have tried this:

vim9script

class X
endclass

def F(x: X = null_object)
enddef

F()

But this results in:

E1013: Argument 1: type mismatch, expected object but got object

Maybe this is not supported yet?

Thanks,
Life.



-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tukcuc%24j79%242%40ciao.gmane.io.


Re: SQL quote sign syntax fail

2023-03-12 Thread Lifepillar
On 2023-03-12, hans.sc...@gmail.com  wrote:
> Hi
>
> I have a PostgreSQL dump file with some data in a COPY..stdin block.
> When an quote sign occur in "O'Malley" the color changes until next quote
> sign
>
> Example in file names.sql:
>
> COPY public.names (name) FROM stdin;
> Thomas O'Malley
> \.
>
> The quote is a legal character in that block and the color should not be
> changed.
>
> After \. on a single line the color should go back to normal.

AFAIK, the syntax is not standard SQL. PostgreSQL's dialect is supported
by my plugin: https://github.com/lifepillar/pgsql.vim.

Unfortunately, currently the plugin has the issue you describe. If you
are interested, please open an issue at
https://github.com/lifepillar/pgsql.vim/issues, and I will try to fix
it.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tukcgh%24j79%241%40ciao.gmane.io.


Search undo history

2023-03-08 Thread Lifepillar
Is there a built-in way or  a plugin to extend / to the undo history?

Use case: working on some code, I deleted a function a few hours ago,
and I wanted to reinstate it. Using :earlier/:later did the job, but
required a bit of trial and error.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tua334%2417oq%241%40ciao.gmane.io.


Re: [Vim 9 script] Is there a way to get the actual type of an object?

2023-01-15 Thread Lifepillar
On 2023-01-15, Bram Moolenaar  wrote:
>> Is there a way to distinguish the class of the value returned by
>> [a function]?
>
> Currently not.  I have been wondering what would be the best way to
> cover this.  We already have type(), but this only returns the basic
> type.  For example for list and list it returns the same
> value.  It can tell the difference between a list and an object, but not
> between two objects from a different class.
>
> You can use typename(), it will include the name of the class.  However,
> it is possible to have the same class name in two separate scripts,
> since they are script-local by default.  Thus this may make you think
> it's the same class while it is not.

Ah, that would probably be enough for my use case, as the test in my
case is for script-local objects only.

> Using "instanceof" would work in many places, but you would need to
> import the class to be able to use it.  If you only want to know if two
> objects are from the same class, that is extra overhead.
>
> Perhaps we need a variant of type() that is specific about the exact
> type.  Then it can also be used to tell the difference between
> list and list.  This will be some work to implement,
> because this will mean a new variable type.

To me this falls into the "nice to have" category: I think that most use
cases can be rewritten (possibly verbosely and not elegantly) in a way
that the need for this is avoided. I have a possibly related use case,
but I will post about it in another thread.

Thanks for the comprehensive reply!
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tq1ob1%24llr%242%40ciao.gmane.io.


[Vim 9 script] Is there a way to get the actual type of an object?

2023-01-15 Thread Lifepillar
Silly example:

vim9script

class Num
  this.n = 0
endclass

class Even extends Num
  def new(this.n)
if this.n % 2 == 1
  throw 'Not even'
endif
  enddef

  def IsPrime(): bool
return this.n == 2
  enddef
endclass

class Odd extends Num
  def new(this.n)
if this.n % 2 == 0
  throw 'Not odd'
endif
  enddef

  def IsDivisibleByFive(): bool
return this.n % 5 == 0
  enddef
endclass

def Random(): Num
  const n = rand() % 16
  return n % 2 == 0 ? Even.new(n) : Odd.new(n)
enddef

const v = Random()
if # v is instance of Odd()
  echo v.IsDivisibleByFive()
else
  echo v.IsPrime()
endif

Is there a way to distinguish the class of the value returned by
Random()?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tq1hm3%24ue2%241%40ciao.gmane.io.


Re: vim9 autoload script modified : How to reload it On-The-Fly

2023-01-12 Thread Lifepillar
On 2023-01-11, N i c o l a s  wrote:
> Hum, thanks a lot Life, after one more check:
>
> *./vimfiles/plugged/foo-helper.vim/autoload/vim9fooscript.vim*
>
> vim9script
>
> *# some many defs func*
>
> export def  *High_Caller*(): void
>Sub_Called(4)
> enddef
>
> def  Sub_Called(code: number ): void
>   *# some job*
> enddef
>
>
> *~/_vimc*
> import autoload './vimfiles/*plugged*/foo-helper.vim/autoload/
> *vim9fooscript*.vim' as *Helper*
> nnoremap io   *Helper*.High_Caller()
>
>
> typing io it echoes  E1091: Function is not compiled:  *vim9fooscript*#
> *High_Caller*

I'd start by removing the "many function defs", and possibly simplifying
the body fo Sub_Called(), and see if I can source without error. Then,
I would start to gradually re-add the removed material until I find what
is causing the error.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tppq9r%248v1%241%40ciao.gmane.io.


Re: vim9 autoload script modified : How to reload it On-The-Fly

2023-01-11 Thread Lifepillar
On 2023-01-11, N i c o l a s  wrote:
>
> effectively, sourcing does not work sorry lifepillar: it echoes to me a
> message E1091 Function HighCaller (below) is not compiled.
>
> And the calling tree is as this :
> nnoremap *foo * Helper. *HighCaller*  () ->
> autoload/vim9fooscript.vim :: *exported *def *HighCaller() *->
> autoload/vim9fooscript.vim :: def *SubCalled*

There may be something else going on in your script, possibly a syntax
error in some function. This trivial example works for me:

~/.vim/autoload/vim9fooscript.vim

vim9script

export def HighCaller()
  SubCalled()
enddef

def SubCalled()
  echo 'I was called!'
enddef

~/.vim/vimrc

import autoload "vim9fooscript.vim" as Helper
nnoremap gG  Helper.HighCaller()

When I start Vim and type gG, Vim echoes 'I was called!'. If I then
change the echo message to something else, save the script and then
:source ~/.vim/autoload/vim9fooscript.vim, I get no errors and gG prints
the updated message. 

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tpn6dm%24u3j%241%40ciao.gmane.io.


Re: vim9 autoload script modified : How to reload it On-The-Fly

2023-01-11 Thread Lifepillar
On 2023-01-11, N i c o l a s  wrote:
> Hi,
>
> Currently modifying an *autoload*/*vim9fooscript*.vim which can be started
> by typing a nnoremap as this :
>
>
>- *_vimrc* :
>
> import autoload './vimfiles/some/thing/*autoload*/*vim9fooscript*  .vim'
> as thatHelp
> *nnoremap* inout  thatHelp.E10_InOut()
>
>
>
>- vimfiles/some/thing/*autoload*/*vim9fooscript*.vim
>
> def Foo which is currently modifying
>
>
> How to force "recompile" the new modified content of def Foo without touch
> the nnoremap ?

Sourcing the autoload script should clear the old definitions and
compile the new ones. See :help vim9-reload.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tpn4bu%2414kt%241%40ciao.gmane.io.


Re: Is there a way to open the ":terminal" in the bottom pane instead of the top pane ?

2022-10-10 Thread Lifepillar
On 2022-10-10, Eric Marceau  wrote:
> I would like to open the terminal in the bottom pane, rather than the
> top pane.
>
> Is there an option that could be specified to allow me to control that?

If you are ok with the bottom window always getting the focus on every
split (not only for terminal windows), you may just:

set splitbelow

Hope this help,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/ti1hhv%2454n%241%40ciao.gmane.io.


Re: Play sound on search wrap

2022-10-07 Thread Lifepillar
On 2022-10-06, Arun  wrote:
> You could try a hack by calling a function that checks for v:warningmsg and
> reset it, in a "statusline" invoked function. Something like:
>
> ---
> fu! CheckWrap()
> if v:warningmsg =~# "^search hit [BT]"
> "Ring bell
> exe "norm! \"
> endif
> let v:warningmsg=""
> endf
> "call CheckWrap using standard statusline
> set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P%{CheckWrap()}
> ---
>
> The above should ring the bell (provided you did not disable it) on search
> wraps.

Aha, hackish, but that does work!

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/thq2ah%24g9e%241%40ciao.gmane.io.


Play sound on search wrap

2022-10-06 Thread Lifepillar
When performing a search, it's easy for me to miss the "search hit
BOTTOM, continuing at TOP" message because my attention is focused on
the matches. For this reason, I'd like a sound of my choice to be played
when the search wraps (using +sound). Is this possible?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/thnahj%24rq5%241%40ciao.gmane.io.


Re: Bugs in visual mode marks?

2022-09-27 Thread Lifepillar
On 2022-09-27, M  wrote:
> You're using cmd token that doesn't switch the modes. The effect is that as
> long as you're in visual mode the < and > marks are not updated. This is
> the way how it works and always worked.

Aha, that's it! In fact, I have switched to use  when I have
migrated to Vim 9 script. Somehow I thought it was a substitute for
:, but there are other differences.

Thanks,
Life

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tgvl7o%24621%241%40ciao.gmane.io.


Re: Bugs in visual mode marks?

2022-09-27 Thread Lifepillar
Source this script:

vim9script

def g:Select(): list
  const lnum1 = getpos("'<")[1]
  const lnum2 = getpos("'>")[1]
  return getline(lnum1, lnum2)
enddef

vnoremap x echo Select()

Then select some line(s) and type \x. What I would expect (and what
I think Vim used to do up to recently, unless I am missing something) is
that the *currently* selected lines are echoed. Instead, the
*previously* selected lines are printed. Can you reproduce it? Is it
a bug?

Tested with Vim 9.0.611.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tgvj5t%24rbc%241%40ciao.gmane.io.


Re: Bugs in visual mode marks?

2022-09-27 Thread Lifepillar
On 2022-09-27, Lifepillar  wrote:
> Today, I checked the value of getpos("'>") after selecting some text,
> and got:
>
> [0, 15, 2147483647, 0]

Now I have seen that the large number is expected. I will try to make
a reproducible example of my issue.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tgvh19%24udl%242%40ciao.gmane.io.


Bugs in visual mode marks?

2022-09-27 Thread Lifepillar
Has something changed recently in the way Visual mode marks are handled?
I have a couple of functions using '<, '> and the like and they have
started misbehaving recently. Today, I checked the value of getpos("'>")
after selecting some text, and got:

[0, 15, 2147483647, 0]

This using Vim 9.0.493 on an M1 Mac. I am investigating the problem, but
I am curious to know whether it is a known (and perhaps solved) issue.

Thanks,
Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tgvgj4%24udl%241%40ciao.gmane.io.


[vim9script] Behavior of has_key()

2022-08-17 Thread Lifepillar
The help entry for has_key() says that the key must be a string. In
legacy Vim script, however, this works fine:

let dd = {42: '42', v:true:  'T', 3.14: '3.14'}
echo dd->has_key(42)
echo dd->has_key(v:true)
echo dd->has_key(3.14)

In Vim 9 script, the behavior is different:

vim9script
const dd = {42: '42', true:  'T', [3.14]: '3.14'}
echo dd->has_key(42) # OK
echo dd->has_key(v:true) # Error, must be string(v:true)
echo dd->has_key(3.14)   # Error, must be string(3.14)

This seems a bit inconsistent to me. I don't have a problem with Vim
9 script being different from legacy script, but I think that either all
the three cases should raise an error, or none of them.

Besides, the documentation does not make it clear that implicit type
casting may happen.

Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tdi4ul%24ik8%241%40ciao.gmane.io.


Re: Build Vim without +vim9script

2022-08-11 Thread Lifepillar
On 2022-08-11, Bram Moolenaar  wrote:
>
>> Is it possible to build Vim without support for Vim 9 script?
>>
>> I would like to build Vim without +vim9script for testing purposes.
>> I have tried to pass --disable-vim9script to ./configure, but it does
>> not recognize the option. And I can't find anything related to Vim
>> 9 script in feature.h.
>
> Simple answer: no.

Cool, thanks for confirming that I am not missing something. I will
build an old version then.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td3rjd%24icc%241%40ciao.gmane.io.


Build Vim without +vim9script

2022-08-11 Thread Lifepillar
Is it possible to build Vim without support for Vim 9 script?

I would like to build Vim without +vim9script for testing purposes.
I have tried to pass --disable-vim9script to ./configure, but it does
not recognize the option. And I can't find anything related to Vim
9 script in feature.h.

Thanks,
Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td3hv7%2440u%241%40ciao.gmane.io.


Re: vim9 exported functions not recognized by ctags

2022-08-11 Thread Lifepillar
On 2022-08-11, N V  wrote:
> So I put it in *somewhereOvertherainbow\*Vim\vim90\.ctags.d

If you put Ctags configuration there, does `ctags --list-kinds=vim`
still use it?

> But it seems to not runnning well : does not displays vim9 exported
> functions

I'm afraid I can't help you with Windows-specific configuration, as I'm
not using Windows.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td3fqm%24i13%241%40ciao.gmane.io.


Re: Use Vim 9 script function for indentexpr?

2022-08-11 Thread Lifepillar
On 2022-08-10, Lifepillar  wrote:
> However, a Vim 9 script function does not seem to be called:
>
> vim9script
>
> def BarIndent()
>   echomsg "BarIndent called"
>   return indent(v:lnum - 1) + 4
> enddef
>
> setlocal indentexpr=BarIndent()
>
> Am I doing anything wrong?

Obviously, I do: the correct signature for BarIndent() is:

def BarIndent(): number

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td2f33%24j9n%241%40ciao.gmane.io.


Re: vim9 exported functions not recognized by ctags

2022-08-11 Thread Lifepillar
Aah, the line for global vars got cut off the Ctags config:

--kinddef-vim=e,export,Vim 9 exported defs
--kinddef-vim=g,global,Vim 9 global variables
--kinddef-vim=K,const,Vim 9 constants
--regex-vim=/^\s*export\s+def\s+([^(]+)/\1/e,export/
--regex-vim=/^\s*(g:\w+)\b/\1/g,global/
--regex-vim=/^(\s*export\s+)?const\s+(\w+)/\2/K,const/
--regex-vim=/^(\s*export\s+)?final\s+(\w+)/\2/K,const/

But you've got the idea :-)
Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td2a0t%24sia%241%40ciao.gmane.io.


Re: vim9 exported functions not recognized by ctags

2022-08-11 Thread Lifepillar
On 2022-08-10, Lifepillar  wrote:
> On 2022-08-10, N V  wrote:
>> Hi,
>>
>> Exported functions in New vim9 are not found by exubérant ctags, universal
>> ctags and not displayed by tagbar plugin
>> https://github.com/preservim/tagbar
>>
>> Is there a work around.

I'd like to elaborate a bit more on my previous reply, as I had just
played a bit more with the issue. In the following, "Ctags" means
Universal Ctags, because that is what I am using.

Ctags supports Vim out of the box. You may check which entities are
supported with `ctags --list-kinds=vim` from the command-line. That
currently gives me:

  a  autocommand groups
  c  user-defined commands
  f  function definitions
  m  maps
  v  variable definitions
  n  vimball filename
  C  constant definitions

Each "kind" (i.e., entity) is identified by a letter, and has a name
(not shown) and description. You may extend Ctags support for Vim by
creating a ~/.ctags.d/vim.ctags configuration file. In that file, you
define new "kinds" and corresponding regexes to recognize them. Each new
kind is also identified by a letter: be careful not to use the already
defined letters!

My current ~/.ctags.d/vim.ctags looks as follows:

--kinddef-vim=e,export,Vim 9 exported defs
--kinddef-vim=g,global,Vim 9 global variables
--kinddef-vim=K,const,Vim 9 constants
--regex-vim=/^\s*export\s+def\s+([^(]+)/\1/e,export/
--regex-vim=/^(\s*export\s+)?const\s+(\w+)/\2/K,const/
--regex-vim=/^(\s*export\s+)?final\s+(\w+)/\2/K,const/

The value of --kinddef is a triple ,,. Each
regex item has three parts /A/B/C/:

- A is the pattern that recognizes an entity;
- B is the value that should be returned for that entity (what Tagbar
  will display);
- C is the identifier of the entity, as defined in --kinddef.

So, the logic is: "if a line matches A, return the value B of kind C".

You may check that your configuration is correct by running `ctags
--list-kinds=vim` again. With the configuration file in place, you
should get:

a  autocommand groups
c  user-defined commands
f  function definitions
m  maps
v  variable definitions
n  vimball filename
C  constant definitions
e  Vim 9 exported defs
g  Vim 9 global variables
K  Vim 9 constants

Now, you need to configure Tagbar. Create
`~/.vim/after/ftplugin/vim.vim` and execute:

:TagbarGetTypeConfig vim

This will paste into the buffer Tagbar's current configuration, which
should look like this:

let g:tagbar_type_vim = {
\ 'kinds' : [
\ 'n:vimball filenames',
\ 'v:variables:1:0',
\ 'f:functions',
\ 'a:autocommand groups:1',
\ 'c:commands:0:0',
\ 'm:maps:1:0',
\ ],
\ }

Now, it's a matter of adding the new kinds, possibly removing those that
you don't need, and reordering the items the way you want them
displayed. I like to use vim9script, so my current script looks as
follows:

vim9script

if !exists('g:tagbar_type_vim')
  g:tagbar_type_vim = {
'kinds': [
  'e:exported defs',
  'f:functions',
  'v:variables:1:0',
  'g:global variables',
  'K:constants',
  'c:commands:0:0',
  'a:autocommand groups:1',
  'm:maps:1:0',
  ],
}
endif

That's it! You may need to restart Vim for the changes to take effect.

You will notice that def's parameters are not shown for exported defs,
and that is intentional, because I don't find them useful. But you may
of course adapt Ctags's regexps to include those, and in general to fit
your taste.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td29is%24153d%241%40ciao.gmane.io.


Use Vim 9 script function for indentexpr?

2022-08-10 Thread Lifepillar
The following silly indent works as expected (of course):

function! FooIndent()
  return indent(v:lnum - 1) + 2
endfunction

setlocal indentexpr=FooIndent()

However, a Vim 9 script function does not seem to be called:

vim9script

def BarIndent()
  echomsg "BarIndent called"
  return indent(v:lnum - 1) + 4
enddef

setlocal indentexpr=BarIndent()

Am I doing anything wrong?

Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td145d%24dph%242%40ciao.gmane.io.


Re: vim9 exported functions not recognized by ctags

2022-08-10 Thread Lifepillar
On 2022-08-10, N V  wrote:
> Hi,
>
> Exported functions in New vim9 are not found by exubérant ctags, universal
> ctags and not displayed by tagbar plugin
> https://github.com/preservim/tagbar
>
> Is there a work around.

I have the same problem. I think that this will be eventually solved
upstream, but in the meantime the following works for me with Universal
Ctags (I haven't had time to refine this, so what follows is just
a sketch):

1. Create ~/.ctags.d/vim.ctags with the following content:

--kinddef-vim=e,export,exported function
--regex-vim=/^[ \t]*export[ \t]+def[ \t]+([^(]+)/\1/e,export/

2. In your .vimrc, or in your after/ftplugin/vim.vim file, inform Tagbar
   about the new entity:

   g:tagbar_type_vim = { 'ctagstype': 'vim', 'kinds': ['e:export'] }

Now, Tagbar should display (only) exported functions. Refer to Tagbar
documentation to learn how to *extend* the already recognized entities
by adding exported functions.

Hope this helps,
Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/td13uj%24dph%241%40ciao.gmane.io.


Re: Setting termcap entries: avoid literal Esc?

2022-08-08 Thread Lifepillar
Thank you both! I hadn't thought about using execute.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tcr61e%24q4p%241%40ciao.gmane.io.


Setting termcap entries: avoid literal Esc?

2022-08-08 Thread Lifepillar
In my vimrc I have entries such as these:

set =^[f
set =^[h

where ^[ is a literal Esc. Is it possible to perform such assignments
without using a literal Esc? For other entries I am able to use the
& form (say, _BE = "\033[?2004h"). I am asking specifically about
entries like the above, which either don't have a corresponding option
in Vim AFAIK () or which have an option with special characters
(t_%i).

I am using Vim 9 script, if that matters.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/tcqu7q%24ddd%241%40ciao.gmane.io.


Re: Inserting on alternate lines?

2022-06-02 Thread Lifepillar
On 2022-06-02, Tim Chase  wrote:
> On 2022-06-02 11:58, Lifepillar wrote:
>> This morning I made a vertical selection with CTRL-V and typed (too)
>> quickly to prepend a quote to the selected lines. I got something
>> like this:
>>
>> "...
>> ...
>> "...
>> ...
>> "...
>> ...
>>
>> For the life of me (pun intended), I cannot do it again. How is it
>> possible to insert text on alternate lines?
>
> Were they long lines that were wrapped?

Either that or a weird glitch in my terminal. Or a hallucination. I went
through the undo file and I couldn't find that change: all the lines
were quoted. Thanks for taking the time to answer!

路
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t7b2pd%24qju%241%40ciao.gmane.io.


Inserting on alternate lines?

2022-06-02 Thread Lifepillar
This morning I made a vertical selection with CTRL-V and typed (too)
quickly to prepend a quote to the selected lines. I got something like
this:

"...
...
"...
...
"...
...

For the life of me (pun intended), I cannot do it again. How is it
possible to insert text on alternate lines?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t7a8l1%24gss%241%40ciao.gmane.io.


Re: %f item in getqflist()

2022-04-25 Thread Lifepillar
On 2022-04-25, Lifepillar  wrote:
> I am looking into parsing a list of strings with an errorformat to
> create a quicklist or location list out of it. Currently, I am doing it
> as follows:
>
> let efm = "%f:%l:%m"
> let what = getqflist({"lines": ["foo:3:bar"], "efm": efm})
> call setloclist(0, what.items)
> echo what.items[0]
>
> This sets the quickfix list as expected (is there a better way?). But
> when I look at `what.items[0]`, I cannot find an item corresponding to
> %f (`foo` in the example). Yet setloclist() sets it. Where is that
> information stored?

Ah, I see: you get the filename from the buffer's number. A new buffer
is created for `foo` is one does not already exist. And when no filename
is parsed from the errorformat, bufnr is 0. Neat!

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t45qkt%24sb3%241%40ciao.gmane.io.


%f item in getqflist()

2022-04-25 Thread Lifepillar
I am looking into parsing a list of strings with an errorformat to
create a quicklist or location list out of it. Currently, I am doing it
as follows:

let efm = "%f:%l:%m"
let what = getqflist({"lines": ["foo:3:bar"], "efm": efm})
call setloclist(0, what.items)
echo what.items[0]

This sets the quickfix list as expected (is there a better way?). But
when I look at `what.items[0]`, I cannot find an item corresponding to
%f (`foo` in the example). Yet setloclist() sets it. Where is that
information stored?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t45ocl%24del%241%40ciao.gmane.io.


Re: Should Darkyellow, Lightmagenta, Lightred be defined in colors/lists/default.vim?

2022-03-20 Thread Lifepillar
On 2022-03-20, Lifepillar  wrote:
> highlight.c (and, formerly, syntax.c) mention the three colors in the
> subject. Curiously, they are not defined in colors/lists/default.vim. Is
> that an oversight or is it intentional?

Aargh, I was looking at syntax.c in an older Vim source. I see that in
highlight.c they are now marked as "No X11". So, that answers my
question.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t17bbi%248fv%242%40ciao.gmane.io.


Should Darkyellow, Lightmagenta, Lightred be defined in colors/lists/default.vim?

2022-03-20 Thread Lifepillar
highlight.c (and, formerly, syntax.c) mention the three colors in the
subject. Curiously, they are not defined in colors/lists/default.vim. Is
that an oversight or is it intentional?

I ask because, AFAICS, all the other colors are defined in default.vim.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t17b4o%248fv%241%40ciao.gmane.io.


Re: Large file - Opening n head lines

2022-03-17 Thread Lifepillar
On 2022-03-17, Ni Va  wrote:
> Is it possible to open a Large File Vim but just only few beginning lines
> of it, edit one of these 50 first lines and then save and quit ?

I don't think that is possible with Vim without the help of some
pre/post-processing tool, but... Vim can edit pretty large files
relatively quickly, if set up properly. Have you tried playing with
Vim's settings already?

Of course, all depends on what "large" and "quick" mean to you. And
I believe that the line length of the edited files is also an important
factor.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t0v0i1%2416vt%241%40ciao.gmane.io.


Re: Avoid jumping cursor after undo

2022-03-16 Thread Lifepillar
On 2022-03-14, Lifepillar  wrote:
> I have defined this function:
>
> fun! Lint()
>   let l:view = winsaveview()
>   keepjumps normal gggqG
>   call winrestview(l:view)
> endf
>
> When the function is executed, the cursor does not move, as expected.
> Unfortunately, pressing u after that makes the cursor jump to the top
> of the buffer. I had hoped that keepjumps would prevent that, but that
> does not seem the case. How can I avoid moving the cursor upon undoing
> (without touching registers)?

I have found a rational for this behaviour (Vim restores the position to
where the undone change has happened), and a way to keep the cursor
where it is:


https://vim.fandom.com/wiki/Restore_the_cursor_position_after_undoing_text_change_made_by_a_script

Perhaps, there is a less hackish way that does not modify the buffer.

Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t0tc0t%2410vm%241%40ciao.gmane.io.


Avoid jumping cursor after undo

2022-03-14 Thread Lifepillar
I have defined this function:

fun! Lint()
  let l:view = winsaveview()
  keepjumps normal gggqG
  call winrestview(l:view)
endf

When the function is executed, the cursor does not move, as expected.
Unfortunately, pressing u after that makes the cursor jump to the top of
the buffer. I had hoped that keepjumps would prevent that, but that does
not seem the case. How can I avoid moving the cursor upon undoing
(without touching registers)?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/t0o0f3%24i9e%241%40ciao.gmane.io.


Re: New User -- regex question(s) ...

2022-03-13 Thread Lifepillar
On 2022-03-09, LOSS PREVENTION <980beadvi...@gmail.com> wrote:
>  I have read, both http://www.vimregex.com/ -and- various sections of
> http://vimdoc.sourceforge.net/htmldoc/help.html. That said, I just can't
> figure out what I'm doing incorrectly. Please follow the live examples
> below:
>
> 1) Using \+ is not working for me in the following example -
> Original 01 --> Theft Attempted or Completed Offense? Completed
> Original 02 --> Theft Attempted or Completed Offense? Attempted
> Broken --> %s/\v\s(Attempted or Completed Offense\?)\s(\u\w\+)\s/,\1,\2,/g

With \v, you should use + instead of \+.

> I cannot find a written reason for this failure.

I have taken a quick look at the help of \v and, in fact, I cannot find that
difference explained in the table. Maybe, it should.

> --Next--
>
> %s/^M//g <--will work from the cmd-line, how do I do this from within a

Re: Dictionary Completion of Capitalized Words

2022-03-05 Thread Lifepillar
On 2022-03-04, Gary Johnson  wrote:
> On 2022-03-04, Bram Moolenaar wrote:
>> Gary Johnson wrote:
>> 
>> > Typing part of a word, then using Ctrl-X Ctrl-K to complete the word
>> > from entries in a dictionary works fine as long as the word (not
>> > a proper noun) is all lower case.  But when a word that is lower
>> > case in the dictionary is capitalized when typed, as at the start of
>> > a sentence or in a title, completion from the dictionary fails.
>> > 
>> > Is there a way to have Ctrl-X Ctrl-K complete a capitalized word
>> > even though it is not capitalized in the dictionary?
>> > 
>> > Example:
>> > 
>> > cornu expands to cornucopia (or cornucopias), but
>> > Cornu results in E486 Pattern not found.
>> > 
>> > I'm using Vim 8.2.4127 in a terminal on Linux.
>> 
>> You can set 'ignorecase' to find matches.  It's not clever though, it
>> will then remove the capital letter.
>
> That's an improvement over what I had been doing.  Thank you.
>
> I always have 'ignorecase' set, but I also have 'smartcase' set.

Have you tried setting infercase?

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/svvn40%24dlr%241%40ciao.gmane.io.


Re: vim/colorschemes: Request For Comments

2022-02-13 Thread Lifepillar
On 2022-02-12, Romain Lafourcade  wrote:
> thanks to the hard work of a small but motivated team, a
> first milestone is finally within reach

As a mostly passive observer of the development of this project, I feel
compelled to thank you for undertaking this time-consuming task with
invincible passion! I can testify that it was no mean feat.

> - due to the _many_ inconsistencies plaguing the originals, we generally
> favored the _spirit_ to the _letter_ so the peachpuff remake (to really
> pick a random example) _is not the original peachpuff_; it still retains
> much of what made peachpuff peachpuff but in a much more usable and
> up-to-date package.

Compatibility (with terminal and GUI environments, and with Vim's own
highlighting definitions) has been greatly improved. This makes the user
experience so much better: to pick a random example, peachpuff used only
0-15 colors in terminals, so activating it in 256-color capable
terminals would leave the user wondering why it didn't look like
peachpuff (or worse, why it looked completely different in different
terminals). But the number of improvements is really huge.

Thanks again for setting the path forward and raising the bar for color
schemes: hopefully, it will become now easier to add new ones, finally
pushing forward https://github.com/vim/vim/issues/1665. Personally, I'd
like to see a joint effort to produce an original and fresh color scheme
created specifically for Vim (9?), in the same way as some other editors
have "their own" branding color scheme. But maybe this is wishful
thinking...

Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/subpn5%24tkq%241%40ciao.gmane.io.


Re: Vim9 import [was Vim9 script feature-complete]

2022-01-05 Thread Lifepillar
On 2022-01-04, Marvin Renich  wrote:
> * Bram Moolenaar  [220104 12:26]:
>> While using:
>>
>>  import "thatscript.vim"
>>
>> Or:
>>
>>  import "thatscript.vim" as that
>>
>> Is nice and short, no need for "from".  The help for ":import" becomes
>> much shorter.  The implementation will also be much simpler.
>>
>> The discussion about the need for using the prefix, whether "as" should
>> be required and other things, seem less important.
>
> Actually, I think the local namespace pollution is the more important
> issue, and requiring "as" and the prefix gives the simpler import syntax
> as an added benefit.

FWIW, my preference, too, goes to using just one form:

import "thatscript.vim" as that

with a mandatory "as" clause. Then, I'd vote for funcrefs and consts as
an aliasing mechanism, as already suggested. I find the argument that
changes to an imported script may break the importing script pretty
compelling, so I would withdraw my proposal of a "use that" command to
indiscriminately import everything into the script's namespace.

Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sr3ooo%243vk%241%40ciao.gmane.io.


Re: [VIM] Re: [VIM] Re: Persistent undo and swapfile

2022-01-03 Thread Lifepillar
On 2022-01-03, Walter Cazzola  wrote:
> On Mon, 3 Jan 2022, Lifepillar wrote:
>
>> On 2022-01-03, Walter Cazzola  wrote:
>>> Out of curiosity: which plugin are you using for the persistent undo.
>>
>> Do you mean, to navigate the (not necessarily persistent) undo history?
>
> Yes but also to have the undoes stored somewhere.

Not sure I understand: persistent undo is a built-in Vim feature (see
Manfred's post). Are you looking for something that Vim does not
provide?

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sqvrkp%247l8%243%40ciao.gmane.io.


Re: [VIM] Re: [VIM] Re: Persistent undo and swapfile

2022-01-03 Thread Lifepillar
On 2022-01-03, Manfred Lotz  wrote:
> Another point might be interesting. In the undo directory there are
> undo files where the real files don't exist any longer. Not sure if
> there is some cleanup procedure avalaible.

I use this command to remove undo files that haven't changed in a long
time:

command! -nargs=0 CleanUpUndoFiles !find ~/.vim/tmp/undo -type f -mtime 
+100d -delete

This goes with this setting:

set undodir=~/.vim/tmp/undo

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sqvrcm%247l8%242%40ciao.gmane.io.


Re: [VIM] Re: Persistent undo and swapfile

2022-01-03 Thread Lifepillar
On 2022-01-03, Walter Cazzola  wrote:
> Out of curiosity: which plugin are you using for the persistent undo.

Do you mean, to navigate the (not necessarily persistent) undo history?
I use undotree (https://github.com/mbbill/undotree). I prefer it over
other choices mainly because it is pure Vim script and it require no or
little configuration.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sqvdpe%242qv%241%40ciao.gmane.io.


Re: Vim9 import [was Vim9 script feature-complete]

2022-01-03 Thread Lifepillar
On 2022-01-03, Marvin Renich  wrote:
> Don't bother with the

>   import MyClass from "myclass.vim"
>   import {someValue, MyClass} from "thatscript.vim"
>
> syntax, and only provide
>
>   import "myclass.vim"
>   import "myclass.vim" as Other
>
> and require use of the namespace prefix:
>
>   Other.MyClass
>
> The first case, without the "as" would default to the file name, with
> leading directories and trailing ".vim" removed

I do not think that using a filename as an identifier is a good idea.
For instance, calling a script 1.vim would automatically make it
non-importable (without "as").

I personally find that using an imported name without a prefix (as it is
currently possible) makes my code terse, and I think that in the limited
scope a plugin that works well. But I understand that Vim9 scripts might
have a broader use, such as generic libraries of functions that can be
used by many scripts. In that context, stricter scoping rules, such as
in Go, are likely a cleaner approach.

How about always requiring a prefix, but allowing explicit namespace
pollution? As in

import "myclass.vim" as Other
use Other  # Makes Other.F() available as just F()

Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sqv7uk%24gb3%241%40ciao.gmane.io.


Re: Vim9 script feature-complete

2022-01-03 Thread Lifepillar
["Followup-To:" header set to gmane.editors.vim.]
On 2021-12-30, Bram Moolenaar  wrote:
> The work on Vim9 script is coming to a point where the syntax and
> semantics are practially done.  There might be some more tests
> uncovering problems that need to be fixed and perhaps some tiny tweaks,
> but otherwise it has been quite stable for the past months.
>
> If you have remarks on something in Vim9 script that you think should be
> different, speak up now!  Soon we'll only make backwards compatible
> changes to avoid breaking existing plugins.

There was a thread about this on HN a few days ago, and one of the
comments suggested to reverse the import syntax so that the imported
script is named first and the imported entities next. A rationale for
this is that it would help automatic completion.

Personally, the thing I still miss is custom types. But that falls into
the category of features to be added when Vim9 script is frozen,
I guess. Other than that, I am really enjoying Vim9 script!

Happy new year!
Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/squjhv%24scm%241%40ciao.gmane.io.


Re: goyo plugin and artifacts in TTY

2021-10-30 Thread Lifepillar
On 2021-10-30, meine  wrote:
> When starting Goyo, artifacts of the previous screen-wide display of the
> text stay. Scrolling though the text doesn't remove them (as opposed to
> Goyo in a GUI, where resizing the window removes the artifacts).

I do not have a solution, but I use Goyo and I cannot reproduce your
issue in my terminal (Apple's Terminal.app). You should provide more
details about your environment: Vim version, OS, terminal.

And have you searched for similar issues at
https://github.com/junegunn/goyo.vim/issues? You may have more luck
reporting your problem there.

Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/slkcrd%24ucf%241%40ciao.gmane.io.


Re: New User Several Questions and Concerns

2021-09-17 Thread Lifepillar
On 2021-09-17, Bernard  wrote:
> I assumed each tab would be identified w/ a number

Yes, that is the case. If you want the number to show up in the tab
label, you may customize the tab line. See `:help setting-tabline`.

> so one can merely type something like ":gototab3"

:3tabnext

(See `:help :tabnext`). Or use gt, as already suggested.

> Furthermore one horizontal line of text of course offers finite space

I don't think there is a way to show tab labels that do not fit, except
by enlarging the terminal (or GUI) window.

You haven't specified what your use case is for lots of tabs. But if you
tend to open each file in a separate tab, that is not how tabs are meant
to be used. You should think of tabs as workspaces (groups of windows),
not files.

Hope this helps,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/si2omg%24jam%241%40ciao.gmane.io.


Re: How to replace pattern with shell command's output using matched pattern

2021-09-04 Thread Lifepillar
On 2021-09-04, rwmit...@gmail.com  wrote:
> I'm just curious, is the file being otherwise edited in vim?  I usually
> just use less to view logs, in which case, a command line filter would be
> more efficient (for me).

Thanks that's a good suggestion in general. In this case, yes, I am
going to perform more editing.

> On Saturday, September 4, 2021 at 11:23:28 AM UTC-4 Tim Chase wrote:
>
>> On 2021-09-04 14:07, Andreas Perstinger wrote:
>> > Alternatively, without using an external command:
>> >
>> > :%s_^\[\(\d\+\)_\="[" . strftime("%c", submatch(1))_
>>
>> This is much better than the suggestion I gave, keeping it all
>> internal to vim. To clean it up, I'd tweak it to
>>
>> :%s/\[\zs\d\+\ze\]/\=strftime("%c", submatch(0))

Learning Vim is a never-ending experience: I didn't know (or remember)
about submatch()!

Can you explain why \zs... \ze is to be preferred to capturing with \(
and \)?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sh0ep4%24q6g%241%40ciao.gmane.io.


How to replace pattern with shell command's output using matched pattern

2021-09-04 Thread Lifepillar
Use case at hand: replace Unix timestamps with date/time in a log file:

[1630720618] unbound[63495:0] info: 127.0.0.1 foo.bar.com  IN
[1630720618] unbound[63495:1] info: 127.0.0.1 foo.bar.com A IN
...

The shell command I'd apply is `date -r `. How would you
perform the substitution?

The desired output is:

[Sat Sep  4 03:56:58 CEST 2021] unbound[63495:0] info: 127.0.0.1 foo.bar.com 
 IN
[Sat Sep  4 03:56:58 CEST 2021] unbound[63495:1] info: 127.0.0.1 foo.bar.com A 
IN
...

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sgvdf3%2413g6%241%40ciao.gmane.io.


Re: [vim9script] Why is a forward declaration needed?

2021-08-19 Thread Lifepillar
On 2021-08-19, Bram Moolenaar  wrote:
> You are using "Call" in Expr(), and Expr is used in an expression
> to set "TrailingArg".  To be able to check the type there, Expr() is
> compiled, which requires "Call" to exist.

Got it.

> NumberLiteral is defined just before setting "TrailingArg".

Too silly of me not to notice that.

> What is tricky here that in principle a variable needs to be defined
> before used, and when used in a function it should be defined before
> that function.  But since compilation is done only when needed, it can
> be defined after the function, so long as it's before compiling it.

Ok, that makes sense.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sfmdd7%24j5r%241%40ciao.gmane.io.


[vim9script] Why is a forward declaration needed?

2021-08-19 Thread Lifepillar
Hi, I have tried to port this TypeScript script:

https://github.com/sigma-engineering/blog-combinators/blob/master/index.ts

to Vim9 script (please find the full code at the end of this message).
It appears to work, but to make it work I had to add a "forward
declaration" of the Call() function:

var Call: func(dict): dict

If I comment out the above line, I get a "E1001: Variable not found:
Call" error, pointing at this line:

const TrailingArg = Map(Sequence([Str(","), Expr]), (args) => args[1])

What baffles me is that Vim doesn't complain in the same way about
NumberLiteral. Does anyone have an explanation for this behaviour?

Using Vim 8.2.3350.

Thanks,
Life.

##
vim9script

# See also: https://github.com/sigma-engineering/blog-combinators

# type TSuccess dict
# type TFailure dict
# type TResult  TSuccess | TFailure
# type TContext dict
# type TParser  func(TContext): TResult

def Success(ctx: dict, value: any): dict
  return { success: true, value: value, ctx: ctx }
enddef

def Failure(ctx: dict, expected: string): dict
  return { success: false, expected: expected, ctx: ctx }
enddef

# Match a string exactly, or fail
def Str(match: string): func(dict): dict
  return (ctx: dict): dict => {
const endIndex = ctx.index + len(match) - 1
if (ctx.text[(ctx.index) : (endIndex)] ==# match)
  ctx.index = endIndex + 1
  return Success(ctx, match)
else
  return Failure(ctx, match)
endif
  }
enddef

# Match a regexp or fail
def Regex(re: string, expected: string): func(dict): dict
  return (ctx: dict): dict => {
const res = matchstrpos(ctx.text, re, ctx.index)
if res[1] == ctx.index
  ctx.index = res[2]
  return Success(ctx, res[0])
else
  return Failure(ctx, expected)
endif
  }
enddef

# Try each matcher in order, starting from the same point in the input. return
# the first one that succeeds. or return the failure that got furthest in the
# input string. Which failure to return is a matter of taste; we prefer the
# furthest failure because it tends be the most useful/complete error
# message.
def Either(Parsers: list): dict>): func(dict): 
dict
  return (ctx: dict): dict => {
var furthestRes: dict = {ctx: {index: -1}}

for Parser in Parsers
  const res = Parser(ctx)
  if res.success
return res
  endif
  if furthestRes.ctx.index < res.ctx.index
furthestRes = res
  endif
endfor
return furthestRes
  }
enddef

def Null(ctx: dict): dict
  return Success(ctx, null)
enddef

# Match a parser, or fail silently
def Optional(Parser: func(dict): dict): func(dict): dict
  return Either([Parser, Null])
enddef

def Many(Parser: func(dict): dict): func(dict): dict
  return (ctx): dict => {
var values = []
var nextCtx = ctx
while (true)
  const res = Parser(nextCtx)
  if (!res.success)
break
  endif
  values->add(res.value)
  nextCtx = res.ctx
endwhile
return Success(nextCtx, values)
  }
enddef

# Look for an exact sequence of parsers, or fail
def Sequence(Parsers: list): dict>): func(dict): 
dict
  return (ctx): dict => {
var values = []
var nextCtx = ctx
for Parser in Parsers
  const res = Parser(nextCtx)
  if (!res.success)
return res
  endif
  values->add(res.value)
  nextCtx = res.ctx
endfor
return Success(nextCtx, values)
  }
enddef

# A convenience method that will map a Success to callback, to let us do
# common things like build AST nodes from input strings.
def Map(Parser: func(dict): dict, Fn: func(any): any): 
func(dict): dict
  return (ctx: dict): dict => {
const res = Parser(ctx)
return res.success ? Success(res.ctx, Fn(res.value)) : res
}
enddef

def Str2Nr(n: string): number
  return str2nr(n)
enddef

# Grammar-specific

# Expr ::= Call | NumberLiteral
# Call ::= Ident '(' [ArgList] ')'
# ArgList ::= Expr (TrailingArg)*
# TrailingArg ::= ',' Expr
# Number ::= '[+-]\?[0-9]\+'
# Ident ::= '[a-zA-Z][a-zA-Z0-9]*'

#
# This seems necessary for Vim to digest what follows:  #
#
var Call: func(dict): dict
#
# Why?  #
#

def Expr(ctx: dict): dict
  return Either([NumberLiteral, Call])(ctx)
enddef

const Ident = Regex('[a-zA-Z][a-zA-Z0-9]*', 'identifier')

const NumberLiteral = Map(Regex('[+-]\?[0-9]\+', 'number'), Str2Nr)

const TrailingArg = Map(Sequence([Str(","), Expr]), (args) => args[1])

const ArgList = Map(Sequence([Expr, Many(TrailingArg)]), (args) => 
flattennew(args))

Call = Sequence([Ident, Str('('), Optional(ArgList), Str(')')])

# Top level parsing function
def Parse(text: string): any
  const res = Expr({ text: text, index: 0 })
  if 

Statusline's minwidth not respected?

2021-08-02 Thread Lifepillar
Vim gurus,
if I set the statusline as follows:

set statusline=X%1MX

the % item does not occupy any space if the buffer is unmodified,
despite the minimum width of one character. Is that expected behaviour?

What I would expect is what I get with:

set statusline=X%1(%M%)X

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/se8cqm%24b7j%241%40ciao.gmane.io.


Re: Help converting function to Vim9 script

2021-07-08 Thread Lifepillar
On 2021-07-07, lgc  wrote:
>> Any idea what would be the best way to convert the snippet above?
>
> Move the `i` variable in the script-local namespace.

Thanks for the thorough explanation. For now, I am keeping a function
instead of a def. But, as you say:

> FWIW, I would still refactor the code in Vim9.  Mainly because of type
> checking, and for better readability.

I'll likely do that, using a script variable as you suggest.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sc6u3t%2411j9%241%40ciao.gmane.io.


Help converting function to Vim9 script

2021-07-04 Thread Lifepillar
The MetaPost plugin in Vim contains the following definition to replace
the n-th occurrence of `beginfig(...)` with `beginfig(n)`:

function! s:fix_beginfigs()
  let i = 1
  g/^beginfig(\d*);$/s//\='beginfig('.i.');'/ | let i = i + 1
endfunction

command -nargs=0 FixBeginfigs call s:fix_beginfigs()

On attempting to convert it to Vim9 script, I came up with this:

def FixBeginfig()
  i = 1
  g/^beginfig(\d*);$/s//\='beginfig(' .. i .. ');'/ | i += 1
enddef

command! -buffer -nargs=0 -bar FixBeginfigs call FixBeginfig()

But this results in 'Undefined variable: i', likely because the command
is not evaluated in Vim9 script context.

Any idea what would be the best way to convert the snippet above?

Thanks,
Life.


-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sbsvdk%24dep%241%40ciao.gmane.io.


Re: syntaxcomplete#Complete() and nested filetypes

2021-06-22 Thread Lifepillar
On 2021-06-22, David Fishburn  wrote:
> Life,
>
> I am not sure I quite understand your use case for the plugin.

Thanks for the feedback. My goal is to have some sort of
context-sensitive completion. My use case is ConTeXt, which can include
MetaPost blocks:

\starttext
  TeX code here: filetype is `context`
  \startMPcode
 % Nested filetype here is `mp`.
 % MetaPost code here.
 % Only `mpSomething` syntax groups should be used for
 % completion.
  \stopMPcode
  TeX code again: filetype is again `context`.
  Only `contextSomething` syntax groups should be used.
\stoptext

Within the ...MPcode block, where a nested filetype is active, I'd like
completion only for that filetype. AFAICT, I can add MetaPost syntax
groups using omni_syntax_group_include_context, but they will be active
throughout the buffer.

The snippet I have posted allows me to do that sort of context-sensitive
completion, but maybe there is a better/more efficient way.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sas9l7%244pe%241%40ciao.gmane.io.


Re: syntaxcomplete#Complete() and nested filetypes

2021-06-21 Thread Lifepillar
On 2021-06-21, Lifepillar  wrote:
> I would like to use syntaxcomplete#Complete() in a filetype that
> includes a nested filetype.

This is what I have so far, which appears to be working in filetype
`foobar` with nested filetype `xyz`:

def foobarcomplete#Complete(findstart: number, base: string): any
  if findstart == 1
syntaxcomplete#OmniSyntaxClearCache()

if len(synstack(line("."), 1)) > 0 &&
  synIDattr(synstack(line("."), 1)[0], "name") ==# '^xyz'
  g:omni_syntax_group_include_foobar = 'xyz\w\+'
else
  unlet! g:omni_syntax_group_include_foobar
endif
  endif

return syntaxcomplete#Complete(findstart, base)
enddef

If you have better ideas, let me know! I especially do not like that
I have to clear the cache.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sappac%243eh%242%40ciao.gmane.io.


syntaxcomplete#Complete() and nested filetypes

2021-06-21 Thread Lifepillar
I would like to use syntaxcomplete#Complete() in a filetype that
includes a nested filetype. The only way I have found so far is to
define my own completion function that checks whether the current
position is within the nested filetype, then calls OmniSyntaxList() with
the appropriate regular expression. Something along these lines:

if synIDattr(...) =~ '^nestedfiletype'
  matches = OmniSyntaxList(['^nestedfiletype\w\+'])
else
  matches = OmniSyntaxList(['^mainfiletype\w\+'])
endif

This is simple enough, but (1) it does not benefit from
syntaxcomplete#Complete() caching, and (2) it requires my own function.

Perhaps, there is a more canonical way to achieve what I want?

Ideally, I would like to set omnifunc=syntaxcomplete#Complete(), and
have Vim figure out the filetype to use for the current completion.
I see that there are some global variables to tweak the completion
behaviour (g:omni_syntax_group_include, ...), but I have not found how
to use them for the my purpose.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sapo54%24bnf%241%40ciao.gmane.io.


Re: Search for pattern in the first few lines of a buffer

2021-06-21 Thread Lifepillar
On 2021-06-21, Yegappan Lakshmanan  wrote:
> Hi,
>
> On Sun, Jun 20, 2021 at 3:59 AM Lifepillar  wrote:
>>
>> I need to programmatically search for a pattern in the first ten lines
>> of a given buffer, and save the match in a variable when found. Say, the
>> pattern is:
>>
>> % KEY = value
>>
>> I need to extract the value if the above appears in the first lines of
>> the buffer. Of course, the state of the buffer's window, such as the
>> cursor's position, etc., and the content of registers should not be
>> affected. How would you do that?
>>
>
> You can use getbufline() to read the first 10 lines of the buffer
> as a list and then use match() to find the index of the item matching
> a pattern in the list. You can then use substitute() or matchstr()
> to extract the value.

That is a simple strategy!

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/sapng8%24vev%241%40ciao.gmane.io.


Search for pattern in the first few lines of a buffer

2021-06-20 Thread Lifepillar
I need to programmatically search for a pattern in the first ten lines
of a given buffer, and save the match in a variable when found. Say, the
pattern is:

% KEY = value

I need to extract the value if the above appears in the first lines of
the buffer. Of course, the state of the buffer's window, such as the
cursor's position, etc., and the content of registers should not be
affected. How would you do that?

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/san735%24vqe%241%40ciao.gmane.io.


Translating complete functions to Vim9

2021-06-19 Thread Lifepillar
Is there a way to turn a completion function (:h complete-functions)
into Vim9 script?

The issue is that such functions are called twice, and they are expected
to return values of different types in each call.

Thanks,
Life.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/salle7%24pfs%241%40ciao.gmane.io.


  1   2   3   >