Re: Feature/plugin dependency checks in plugins

2019-02-18 Thread Luc Hermitte


Hi,

> What is the best practice when a plugin needs a minimum version of
> Vim with certain features, or on some other plugin? 

1- I try to document the identified requirement
2- I provide emulation of new features I use when this is possible.

See for instance 
https://github.com/luchermitte/lh-vim-lib/blob/master/autoload/lh/list.vim

3- Regarding the dependency to other plugins I usually expect the plugin I 
depend on to be up-to-date. And I provide the dependencies in the documentation 
of my plugin. I also highly recommend people to use plugin managers that 
understand dependencies (like VAM or vim-flavor). But I'm perfectly aware that 
people usually fancy plugin managers that download multiple plugins in parallel 
or have some other smooths feature. Personally I'm mainly interested in 
dependencies management.

BTW, version requirements can be expressed with vim-flavor.


> Do you check
> for the version (and if so how) or do you check for some each
> feature or for some feature which is indicative that the others
> exist too? Is it best to check when the plugin is loaded or in
> each function which needs a certain feature? What do you do when
> the requirements aren't met --- issue a warning/error message or
> just silently do nothing? 

"Ignore" or "error" when the plugin file is loaded. But definitively "error" 
when a plugin feature is triggered and that the requirements are not met.
It depends on whether the plugin is critical or not. And whether it could be a 
non-critical dependency on some other plugin. For instance, my refactoring 
plugin implements a refactoring that depends on a plugin (lh-tags) that depends 
on ctags. It also implements other refactoring. I don't want to notify the end 
user that lh-tags cannot be used because ctags is not installed just because 
lh-tags is automatically installed (VAM) when the refactoring plugin is 
installed.


> My preference is definitely to issue a
> message, but I'm concerned that it may be too noisy and get lost
> if it is issued at loading time. 


> There is also the concern that if
> you are using a plugin manager some other plugin which you depend
> on may not be loaded yet even though it eventually will be.

My plugin manager updates the runtimepath before any file from plugin/ is 
sourced. Then the dependencies are mainly done through autoloaded function. In 
case I depend on a mapping or a command, I explicitly source the files that 
defines it with :runtime.


HTH

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: How to debug a vim plugin?

2018-12-10 Thread Luc Hermitte
Hi,

> I am wondering how to debug a vim plugin (for example, the following
> one) in an efficient way.
> 
> [...]
> 
> Does anybody have any tips on how to debugging vim plugins? Thanks.


In my lh-vim-lib [1] library plugin I provide two sets of tools
- log functions [2] that can fill the qf window with the log messages 
automatically -- other logging frameworks fail to automatically link to the 
line where the log is emitted
- assert functions [3] for doing some design by contract. They permit to fail 
fast in case of unexpected value detected / dump the current callstack / start 
the debugger

It also provides a function that decodes displayed callstacks on error [4]

I also use a unit test framework [5] for unit testing functions.

[1] https://github.com/LucHermitte/lh-vim-lib
[2] https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Log.md
[3] https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/DbC.md
[4] 
https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Callstack.md#lhexceptionsay_what
[5] https://github.com/LucHermitte/vim-UT

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Shortcut to jump to the start of the current method in C++

2018-06-22 Thread Luc Hermitte
Hi,

> I'm looking for ways to quickly navigate and/or get contextual
> information about the structure of a large C++ codebase I'm editing
> in Vim.
> 
> [...]
> Is there a trivial way to fix `[m` to work as advertised?  If not, is
> there an alternative, perhaps as a plugin?

The only solution I've found so far consist in using an external tools to 
obtain function boundaries, and from there having a way to fi [m, ]m, and even 
provide a "select-function" operator.

I've implemented a solution in my lh-cpp plugin [1] which requires a few other 
plugins [2] to work. In particular, in this case there is no way to avoid 
lh-dev and lh-tags dependencies.
The solution implemented has been described on vi.SE [3]

[1] https://github.com/LucHermitte/lh-cpp/
[2] https://github.com/LucHermitte/lh-cpp/#installation
[3] https://vi.stackexchange.com/a/7942/626

Regards,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: conditional mapping of , depending on whether plugin exists

2018-05-30 Thread Luc Hermitte
Hi,

- Mail original -
> I use https://github.com/terryma/vim-smooth-scroll and so I bind
>  &  to ":call smooth_scroll#down(, 5, 2)" &
> ":call smooth_scroll#up(, 5, 2)" respectively. However I
> would like  &  to default to their original behaviour if
> the smooth scroll plugin isn't loaded.
> 
> I've tried this:
> 
> if exists('g:loaded_smoothscroll')
>   noremap   :call smooth_scroll#up(, 5, 2)
>   noremap   :call smooth_scroll#down(, 5, 2)
> endif
> 
> but strangely it ignores the mapping if I load it like that. That
> means the exists('g:loaded_smoothscroll') check failed, but doing an
> :echo exists('g:loaded_smoothscroll') does indeed return 1. I'm
> guessing at the moment of sourcing the vimrc g:loaded_smoothscroll
> was 0, then it got set to 1 after after the mapping got read. How do
> I get around that?
> 
> If it helps I actually put the variable let g:loaded_smoothscroll = 1
> into the plugin/smooth_scroll.vim file (which did not exist in the
> author's original version, I had to fork it myself). Is that the
> correct place to put the g:loaded_smoothscroll variable?

No, it's not.
Autoload plugins aren't expected to have an anti-inclusion guard. Beside, plain 
plugins are loaded **after** the .vimrc file has been sourced.

What you can do instead is to check whether the file exists with 

if !empty(globpath(, 'autoload/smooth_scroll.vim'))
nnoremap ...


This needs to be done **after** your plugin manager has kicked in to fill the 
`` option.


HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: substitue( optimize

2018-02-13 Thread Luc Hermitte
Hello Nicholas, 

> After reading a file and getting 1 million lines' List, I need to
> make similar substitutions over matched lines ~500 times with this
> func:
> 
> 
> fun! foo#set_new_val(ressource) abort "{{{
> 
>   " position
>   let pos  = foo#getpos_ress(a:ressource)
>   let pres = foo#geth_presence(a:ressource)
>   let s:xml[pos] = substitute(s:xml[pos],'false\|true',pres,"")  <<<
>   HERE
> 
>   " Slave/Voie01 to Voie08
>   for idx in [1,2,3,4,5,6,7,8]   <<< HERE
>   let pos = foo#getpos_ress(a:ressource.'/bar0'.string(idx))
>   let s:xml[pos] = substitute(s:xml[pos],'false\|true',pres,"")<<<
>   HERE
>   endfor
> 
> endfu"}}}
> 
> 
> 1/ Can I optimize this function ?

So far my experiments on the subject taught me that we are best avoiding :for 
and :while constructs when performances matter.
If you can use map() instead, do!

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: What is the fastest way to detect modifications to any listed buffer?

2017-12-07 Thread Luc Hermitte
Hi,

> I would like an indicator in my 'titlestring' that informs me if ANY
> changes are present in ANY listed buffer.  This would be more like a
> global indicator for the 'modified' setting.  What is the most
> efficient way to do this?
> 
> Currently, I've taken the naive approach:
> 
> function! g:ChangesExist()
> let l:bufferList = filter(range(1, bufnr('$')), 'buflisted(v:val)')
> for l:bufferNumber in l:bufferList
> 
> if getbufvar(l:bufferNumber, '')
> return 1
> endif
> endfor
> return 0
> endfunction
> 
> 
> This seems like the most direct method, but I'm wondering if there's
> some simple option or function call that I'm missing...

If speed is really that important, get rid of the loop and use something like

   return !empty(filter(bufferList, "getbufvar(v:val, '')"))

or, in a single step:

   return !empty(filter(range(1, bufnr('$')), "buflisted(v:val) && 
getbufvar(v:val, '')"))

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Handling differences in different plugins for the same type of operation

2017-11-07 Thread Luc Hermitte
Hi,


> Having one plugin for all languages sound great. Is there any
> documentation on how to add a language to your plugin?

There is an embryo of documentation on the subject which I see is not up-to 
date :(

If you open the files in autoload/lh/refactor/{ft}.vim, you should see plenty 
examples.

An important point, the Extract-Method refactoring relies on ctags, and I need 
to work on it as I remember there is a pending bug.


> I'd like Python and Go support specifically if at all possible.

I don't know Go. In Python I only have Extract-Variable and a likely bugged 
Extract-Method -- I can't remember the last time I've using it.

But honestly, I suspect you'll have far better results with the two other 
plugins dedicated respectively to Python and to Go. 

Currently, I'm spending my energy on other but sometimes related topics: 
- https://github.com/LucHermitte/lh-style/
- and https://github.com/LucHermitte/lh-vim-lib/blob/master/doc/Project.md 
integration in buildToolsWrapper.

Regards,
-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Handling differences in different plugins for the same type of operation

2017-11-06 Thread Luc Hermitte
Hi,

> For C with relatives (C++, Java, ...) there seem to be vim-refactor,
> https://github.com/LucHermitte/vim-refactor.
> 
> Even if these work they are no where close to a uniform interface.
> How do you guys handle such issues, stick with the differences,
> remap until insane, or something else?

I don't use multiple plugins providing a similar feature. Mainly because I'm 
implementing most of what I use regarding source code manipulation.


> I think it would be great if i could have a uniform interface to use
> for refactoring regardless of which language i happen to use at the
> moment. Remembering three different mappings for refactoring and
> when each one applies steal my focus from what i would like to do.


I can only speak for vim-refactor that I'm maintaining. Two things, the plugin 
tries to be as generic (i.e. language independent) as possible, and if your 
language isn't supported it could be added. However, this is a generic and vim 
based plugin. Dedicated plugins that rely on external tools will certainly do a 
better job.
The languages currently supported are the ones I'm working with (C++ and 
family, vim, and bash essentially)

Also, back to your concern, the mappings can be remapped as they are all 
`mappings` (1). However, they all work in two steps: first we extract, 
then we go manually where the extracted thing should be defined and we paste it 
there. I don't know how the extract-refactorings from the other plugins are 
meant to be used.


BTW, I'm becoming confident that the future of vim-refactor, and some other 
plugins, will be to leave its/their place to plugins compatible with Language 
Server Protocol.

(1) 
https://github.com/LucHermitte/vim-refactor/blob/master/plugin/refactor.vim#L127

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: When I using dictionary, how can I add items using my input order?

2017-11-06 Thread Luc Hermitte
Hi,

You can't, dictionaries are just hash tables, there is no ordering you can 
count upon.

You'll have either to record a list of the keys in the order you desire, or 
give up on the big dictionary and use a list instead -- either a list of lists, 
or a list of dictionaries.


If you don't need the dictionary for anything else, no need to extract all the 
information.

You should be able to achieve your result the following (which would be more 
efficient BTW, but I doubt you'd perceive any difference on real code)

   let lines = filter(getline(1, '$'), 'v:val !~ "^\\s*$"')
   call map(lines, 'substitute(v:val, "^\\s*", "", "")')
   let names = map(copy(lines), "substitute(v:val, '\\s*[;,].*$', '', '')")
   let newlines = map(copy(names), '"reg ila_".v:val.";"')
   call setline(curr_line, newlines)

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Advice needed: best practices for vim plugin testing

2017-10-20 Thread Luc Hermitte
Hi,

> However my concerns are broader as I'm trying to figure out ways of
> having a
> vim project maintained by different people but enforcing that their
> coding
> standards/modifications adhere to a test framework.

So, you're not looking for unit testing as there exists quite a few projects, 
but for linters it seems like vint 
https://github.com/Kuniwak/vint

I've even seen an external tool for github (1) that automatically tries to 
execute the linter on code pushed -- alas I can't remember the name, or did it 
stop supporting vim, I can't tell.

Anyway, I usually just unit-test my plugin with a mixture of my vim-UT (1) and 
of vimrunner (3) that I've even registered in travis-ci which gives me little 
nice badges (4).

(1) https://github.com/marketplace
(2) https://github.com/LucHermitte/vim-UT/
(3) https://github.com/LucHermitte/vim-UT/blob/master/doc/rspec-integration.md
(4) https://github.com/LucHermitte/lh-vim-lib#lh-vim-lib-v400---

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Do you use in your plugin mappings?

2017-09-26 Thread Luc Hermitte
Hi,

> I have a question for you plugin developers (but I am interested also
> in a user's perspective). What do you think is the best approach to 
> deal with a conflicting mapping (i.e., a mapping already defined
> elsewhere) in a plugin?
> 
> I currently define my plugin's mappings with , but from time
> to time users report `E227: mapping already exists` errors as bugs, 
> so I am not sure that this is the best approach.


I do use  in my plugins. But only if the user doesn't override the 
default keybinding with his own. I rely on mappings to do so.

If the user report the error, well we need to explain her/him what can be done 
to silence the error. The user has to make a choice which we cannot do for 
her/him: either to continue with the keybinding defined in the .vimrc or 
provided in another plugin, or to choose another keybinding for our plugin.



In my ftplugins, I've used  ged mappings a few times, but I'm not 
sure this is the best thing to do.
Which reminds me in a few places I've replaced  with another approach 
that issues a less intrusive warning.

It's used with:
nnoremap TogglePreviewIfHold :Toggle Cpreview_if_hold
call lh#mapping#plug({'lhs': 'tpw', 'rhs': 
'TogglePreviewIfHold'}, 'n')

With lh#mapping#plug being defined over there: 
https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/mapping.vim#L99

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: source or load an autoload script

2017-08-18 Thread Luc Hermitte
Hi, 

> > I've written more on the subject on SO:
> > https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
> > 
> Ok Luc, Vimscript modified as described.
> 
> Than when I launch :w! | so% | MK, nothing is took on the fly.
> 
> I modify maxTimes allowed to attempt some jobs in my script but
> passing it from 20 to 15 let show 20 after launch.

A few:
- you've forgotten the `dict` attribute
- if your version of vim is to old, `function('s:funcname')` won't work.
- you still have a useless and undesired anti-reinclusion guard in your 
autoload plugin

BTW, if you wish to add methods to an object that already exists, they'll have 
to be injected on a reference of the object as you won't execute whatever#new() 
on an object that already exists. That's the reason behind by 
lh#object#inject_method(): 
https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/object.vim#L96

Here is a patched, and untested, version of your file.


-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


trigger2.vim
Description: Binary data


Re: source or load an autoload script

2017-08-18 Thread Luc Hermitte
Hi, 

> > I've written more on the subject on SO:
> > https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268
> > 
> Ok Luc, Vimscript modified as described.
> 
> Than when I launch :w! | so% | MK, nothing is took on the fly.
> 
> I modify maxTimes allowed to attempt some jobs in my script but
> passing it from 20 to 15 let show 20 after launch.

A few:
- you've forgotten the `dict` attribute
- if your version of vim is to old, `function('s:funcname')` won't work.
- you still have a useless and undesired anti-reinclusion guard in your 
autoload plugin

BTW, if you wish to add methods to an object that already exists, they'll have 
to be injected on a reference of the object as you won't execute whatever#new() 
on an object that already exists. That's the reason behind by 
lh#object#inject_method(): 
https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/object.vim#L96

Here is a patched, and untested, version of your file.


-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


trigger2.vim
Description: Binary data


Re: source or load an autoload script

2017-08-18 Thread Luc Hermitte


De: "Ni Va" <nivaem...@gmail.com>
> OK. My problem is that I don't see effect when I modify a vimscript.
> In the joined screen, you can see two vimscript. The right one is a
> 'class' instanciated in the left one. Then a simple command MK call
> MakeMyVim.
> 
> So, if I modify my vimscritp class and launch MK command, I don't see
> effect of my change as if it was not sourced.

That seems normal. trigger#new()['setup'] cannot be updated without calling 
new() again.
My take on the subject: never define methods this ways. Prefer to define a 
s:method and bind it in the constructor/creator function with

let new_obj.method_name = function('s:method_implementation')

First it'll allow reloading. But also, it'll improve greatly debugability.

I've written more on the subject on SO: 
https://stackoverflow.com/questions/40254993/how-to-unload-a-vim-script-after-sourcing-it-and-making-changes-to-it/40257268#40257268

BTW, autoload plugins don't need anti-inclusion guards. It makes no sense there.

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: standard way include plugin as a dependency of another plugin

2017-08-01 Thread Luc Hermitte
I've made a small (pathname) error in my answer, see the correction below.

- Mail original -
> De: "Luc Hermitte" <hermi...@free.fr>
> À: "vim use" <vim_use@googlegroups.com>
> Envoyé: Mardi 1 Août 2017 13:33:17
> Objet: Re: standard way include plugin as a dependency of another plugin
> 
> Hi,
> 
> (Sorry, it seems I've deleted the original message, and I'm not
> answering to the mail I should be answering to).
> 
> > On 30/07/2017 04:40, sash...@gmail.com wrote:
> > > I'm writing a plugin and want it to depend on another plugin
> > > installed. At the moment I just have a line
> > > 
> > > source 
> > > 
> > > in my plugin that pulls in that plugin. Is there a standard way
> > > of
> > > doing this or do plugin authors just invent their own way? Could
> > > I
> > > use Vundle here instead?
> 
> 
> There is no standard way of proceeding. Also there are two sides to
> the question:
> 1- making sure what we depend upon is installed;
> 2- making sure what we depend upon is defined.
> 
> Beside the actual answer will depend on what you are actually
> depending upon.
> 
> 1- Regarding availability
> a- Most people simply document the dependency(/ies), and it's up to
> the end-users to make sure every dependency is properly installed.
> In all cases, I consider that **documenting is mandatory**.
> 
> 
> b- Some will use git submodules to make this as simple as possible.
> The only, and main disadvantage, as Lifepillar said, is that a plugin
> may be installed several times. An incorrectly written plugin may
> even duplicate events. We could also experience very tricky bugs
> when several versions of a same plugin are installed.
> 
> IMO, this is not a good solution.
> 
> 
> c- A few of us are specifying the dependencies for the only two
> plugin managers that support dependencies. I even go further and
> advocate their use. Unfortunately, the popular plugin managers are
> the simple ones, which don't understand dependencies so far.
> 
> The only two plugin managers that support dependencies (and that I'm
> aware of at this moment) are:
> - VAM: https://github.com/MarcWeber/vim-addon-manager (through
> vim-py)
> - VimFlavor: https://github.com/kana/vim-flavor
> 
> Even if you're not using them, nor expect to ever use them, I highly
> recommend that you specify the dependencies of your plugin for these
> two plugin managers. IOW, you'll have to define an addon-info.json
> file and a VimFlavor file -- unfortunately they don't share a common
> syntax. :(
> 
> You'll find plenty examples in my plugins. See for instance:
> https://github.com/LucHermitte/lh-brackets
> 
> 
> d- Vim 8 packages don't solve anything. We can still have multiple
> versions of a same plugin installed (which is clumsy and bad), and
> they are not able to automatically install the dependencies.
> 
> If there was a notion of "environment" like we have in Python or
> conda, or of "sandbox" like with Haskell or nix, then may be we
> could have multiple packages that contain different versions of a
> same plugin. So far and AFAIK, this is not the case. Hence my
> current stance.
> 
> 
> 
> 2- Regarding "sourcing"
> 
> a- Before Vim7, we had to source plugins where global functions,
> mappings, abbreviations, command, etc. were defined.
> 
> A simple way was to check for something we need, and if it isn't
> detected as defined, then we explicitly source the dependency.
> 
>   if ! exists('*SomeGlobalFunction')
> runtime plugin/MyDependencyThatDefineSomeGlobalFunction.vim
> if ! exists('*SomeGlobalFunction')
>   echoerr "WARNING: MyDependencyThatDefineSomeGlobalFunction
>   isn't installed. MyFooBar plugin is disabled. Please see "
> endif
>   endif
> 
> Or if you don't care about sourcing something that may have already
> been sourced, you could simply type:
> 
>   runtime plugin/MyDependencyThatDefineSomeGlobalFunction.vim
>   if ! exists('*SomeGlobalFunction')
> echoerr "WARNING: MyDependencyThatDefineSomeGlobalFunction isn't
> installed. MyFooBar plugin is disabled. Please see "
>   endif
> 
> You could also check the plugin version in case it stores its version
> number in its `g:loaded_MyDependencyThatDefineSomeGlobalFunction`
> header-gate variable. This has been described in another answer.
> 
> 
> (In case of definitions done in filetype plugins, what we had to do
> was a little bit trickier)
> 
> 
> b- Now, we are past Vim 7. Vim 7 has introduced autoload plugins and
> their autoloaded functions.
> Modern 

Re: standard way include plugin as a dependency of another plugin

2017-08-01 Thread Luc Hermitte
Hi,

(Sorry, it seems I've deleted the original message, and I'm not answering to 
the mail I should be answering to).

> On 30/07/2017 04:40, sash...@gmail.com wrote:
> > I'm writing a plugin and want it to depend on another plugin
> > installed. At the moment I just have a line
> > 
> > source 
> > 
> > in my plugin that pulls in that plugin. Is there a standard way of
> > doing this or do plugin authors just invent their own way? Could I
> > use Vundle here instead?


There is no standard way of proceeding. Also there are two sides to the 
question: 
1- making sure what we depend upon is installed;
2- making sure what we depend upon is defined.

Beside the actual answer will depend on what you are actually depending upon.

1- Regarding availability
a- Most people simply document the dependency(/ies), and it's up to the 
end-users to make sure every dependency is properly installed.
In all cases, I consider that **documenting is mandatory**.


b- Some will use git submodules to make this as simple as possible.
The only, and main disadvantage, as Lifepillar said, is that a plugin may be 
installed several times. An incorrectly written plugin may even duplicate 
events. We could also experience very tricky bugs when several versions of a 
same plugin are installed.

IMO, this is not a good solution.


c- A few of us are specifying the dependencies for the only two plugin managers 
that support dependencies. I even go further and advocate their use. 
Unfortunately, the popular plugin managers are the simple ones, which don't 
understand dependencies so far.

The only two plugin managers that support dependencies (and that I'm aware of 
at this moment) are:
- VAM: https://github.com/MarcWeber/vim-addon-manager (through vim-py)
- VimFlavor: https://github.com/kana/vim-flavor

Even if you're not using them, nor expect to ever use them, I highly recommend 
that you specify the dependencies of your plugin for these two plugin managers. 
IOW, you'll have to define an addon-info.json file and a VimFlavor file -- 
unfortunately they don't share a common syntax. :(

You'll find plenty examples in my plugins. See for instance: 
https://github.com/LucHermitte/lh-brackets


d- Vim 8 packages don't solve anything. We can still have multiple versions of 
a same plugin installed (which is clumsy and bad), and they are not able to 
automatically install the dependencies.

If there was a notion of "environment" like we have in Python or conda, or of 
"sandbox" like with Haskell or nix, then may be we could have multiple packages 
that contain different versions of a same plugin. So far and AFAIK, this is not 
the case. Hence my current stance.



2- Regarding "sourcing"

a- Before Vim7, we had to source plugins where global functions, mappings, 
abbreviations, command, etc. were defined.

A simple way was to check for something we need, and if it isn't detected as 
defined, then we explicitly source the dependency.

  if ! exists('*SomeGlobalFunction')
runtime plugin/MyDependencyThatDefineSomeGlobalFunction.vim
if ! exists('*SomeGlobalFunction')
  echoerr "WARNING: MyDependencyThatDefineSomeGlobalFunction isn't 
installed. MyFooBar plugin is disabled. Please see "
endif
  endif

Or if you don't care about sourcing something that may have already been 
sourced, you could simply type:

  runtime plugin/MyDependencyThatDefineSomeGlobalFunction.vim
  if ! exists('*SomeGlobalFunction')
echoerr "WARNING: MyDependencyThatDefineSomeGlobalFunction isn't installed. 
MyFooBar plugin is disabled. Please see "
  endif

You could also check the plugin version in case it stores its version number in 
its `g:loaded_MyDependencyThatDefineSomeGlobalFunction` header-gate variable. 
This has been described in another answer.


(In case of definitions done in filetype plugins, what we had to do was a 
little bit trickier)


b- Now, we are past Vim 7. Vim 7 has introduced autoload plugins and their 
autoloaded functions.
Modern plugins will use autoload plugin files to store their functions. Most of 
the time this is just to speedup the starting time. Sometimes, this is because 
some of us are aware this is the best way to define libraries.

This time instead of checking whether a particular symbol is defined in order 
to source on the fly, we simply call the autoloaded functions. Given their 
name, foo#bar#func(), Vim will know that if the function doesn't exist then it 
must execute `:runtime foo/bar.vim`. If the function still doesn't exist, Vim 
will issue an error message.
Sometimes, you'll see a few issues from the users, of your plugin, that have 
skipped the installation procedure you have described in your plugin 
documentation.


Of course if you're not trying to execute a function defined in an autoload 
plugin file, you're back to square 2.a-.

Regards,
-- 
Luc Hermitte

-- 
-- 
You received this 

Re: Dynamically name commands in vimscript

2017-04-19 Thread Luc Hermitte
Hi

> let s:modules = split(glob("modules/*"))
> 
> for s:module in s:modules
>   let s:module_name = split(s:module, "/")[-1]
>   let s:prefix = toupper(s:module_name[0]) . s:module_name[1:]
>  
>   function! {s:prefix}()
> echo "inside " . s:prefix
>   endfunction
>   command! {s:prefix} call {s:prefix}()
> endfor
> 
> I've tried with no luck:
> command! s:prefix call {s:prefix}()
> command! prefix call {s:prefix}()


You're looking for `:exe`

-> exe 'command! '.s:prefix.' call '.s:prefix.'()'

Regards,
-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: How to determine what a "bare-bones" vim is for a plugin

2017-03-18 Thread Luc Hermitte
Hi,

> Some plugin authors understandably require that any issue reports to
> be reproducible on a "bare-bones" vim. [...]
> 
> So, in general, given a plugin, how does one determine what is the
> "bare-bones" vim it's author has assumed?

As a plugin author, I find legit issues related to incompatibilities with other 
plugins. However, I do need to know what other plugins are installed. Even 
better if you (end-user) are able to determine which plugin is incompatible 
with mine, it's even better. 
First because this will permit me to quickly converge to a solution. But also 
this will permit me to make sure: either this won't happen again, or this will 
permit me to add a few words on the subject in my plugin documentation.

However, if the issue is related to `:map-`, well I'd rather see my 
end-users aware able to solve this by themselves, but yet I know that sometimes 
I need to explain them what they can do.

What you need to see, is that most of us expect you to investigate by yourself 
what causes the issue, or what scenario permits to reproduce it. In other 
words, it's your job to determine the Minimum Working Example. From there if 
you're able to say "setting xxx" or "installing yyy" cause incompatibilities, 
well you'll have done a good job. One from which we could work efficiently on 
your issue. 
Of course, the issue could be completely unrelated to other plugins... That's 
where the exact scenario that permits to reproduce the issue is important.

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: isolate vim environment for plugin development

2017-03-10 Thread Luc Hermitte
Hi,


> how do I isolate vim environment?
> 
> The objective is to test and develop several different plugins
> without interference.
> 
> I don't want to mess my own vim "stable" setup.
> 
> For that end a setup with its own vimrc file, own variables (for
> instance using a different $HOME than the one used by vim) and
> folders would be nice.
> 
> I was trying to do this thru a bash script but could not achieve the
> desired goals (changing the $HOME variable and setting up vim with a
> different vimrc was not enough).
> 
> So before diving into details/scripting/etc I would like to know if
> you guys have a working solution.

New plugins are loaded through a plugin manager (VAM). In order to not add mess 
in all sessions, I simply Activate manually the Addons where I test them.

Regarding the maintenance of core plugins that may impact every other plugins 
(that's the case with my lh-vim-lib library plugin). I do branches and I don't 
reload the (auto/ft/0)plugin in the session I use to maintain my vim scripts. 
However I load and reload plugins either manually, or by restarting my (g)vim 
testing sessions if the changes are to complex. If I need to revert to a stable 
situation, I just need to checkout the stable branch.

I also have unit tests where I check the result of vim functions, and 
integrated test where I execute more complex sequences and check the state of 
my buffer afterwards. The unit tests can be executed from within a vim session 
[1]. The integrated tests are executed with vimrunner and a small addition that 
enable me to check the results on travis -- which permits me to check the 
behaviour of my plugin of a old vim 7.3-429.


I guess that instead of fighting with $HOME, you could also use Vim 8 packages. 
In "normal" sessions, load the default package, in test sessions, load sessions 
associated to the plugins being modified. IMO vim already has everything we 
need on this topic. Of course we also need a clear workflow that takes 
advantage of this.

[1] https://github.com/LucHermitte/vim-UT

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Compile and Run Java Projects

2016-10-18 Thread Luc Hermitte
Hi,

You should instead use the integrated :make/quickfix feature of vim. You'll 
have a much better user experience.

First be sure that you have set javac as the make program. It's best done by 
sourcing compiler/javac.vim
-> :runtime compiler/javac.vim

I would have done it in a java ftplugin, but as I'm not a Java developer, I'm 
not sure this is a good default setting. So, let's put it in your function.


```vim
command! MakeAndRun :call s:CompileAndRunFolderJava()

function! s:CompileAndRunFolderJava() abort
   runtime compiler/javac.vim

   " old trick to detect compilation errors - part 1
   " --- The following code is borrowed from LaTeXSuite
   "   close the quickfix window before trying to open it again, 
   "   otherwise whether or not we end up in the quickfix window 
   "   after the :cwindow command is not fixed.
   cclose " used to detect errors
   let winnum = winnr()

   " compile all java files in folder of the current buffer
   make %:p:h/*.java

   " old trick to detect compilation errors - part 2
   if winnum == winnr() " => no error detected
 " run Main java file in that folder
 :!(cd .. && java %:p:h:t.Main)

 " delete all the .class files in that folder
 :!rm %:p:h/*.class
   endif

   " :echomsg "Done"
endfunction
```

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Recognize function name from function number

2016-09-08 Thread Luc Hermitte
Hi,

> I have some called functions from each others and an error occurs at
> call of one of them :
> 
> Error detected while processing function
> 347[10]..342[4]..348[4]..346:
> 
> How can I know the name out of the number of function that causes
> error ?

It looks like functions defined on dictionaries (1), instead on functions added 
later on the dictionary (2).
   (1) :function dict.fname()
   (2) :function s:fname() dict
   :let dict.fname = function('fname')

If not the name, you can access the function definition with 
  :function {42}

See :h anonymous-function

I've stopped to use them in order to be able to decode the backtrace in my 
logging framework.

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


s/--remote-expr/job_start ?

2016-09-07 Thread Luc Hermitte
Hi,

In my attempt to execute (pure) VimL functions in the background (*) (which is 
quite difficult without thread-safety), I was thinking of executing my function 
on a second/remote vim server.

I know I could play with --remote-send and --remote-expr, but could I use job 
or channels instead?

As far as I know, Vim isn't a TCP server that'll be waiting for whatever I 
could send to it. I'm not sure this is possible, but still I'm quite confident 
this scenario belongs to the ones that triggered this new extension.


(*) I'm converting tag names into spellfile entries.
-- 
Luc Hermitte, who isn't sure whether the question belongs to vim-dev or vim_use

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Create Autocompletion snippets for Custom Code

2016-08-25 Thread Luc Hermitte
Hi,

> I am looking into that. I am beginner/intermediate level of Vim user.
> And I find it really hard to add my own custom snippet in the
> mu-template. Can you give me some ideas of how to add simple
> snippets.
> 
> For example
> ---
> 
> I would like to add the following for the trigger `openr`.
> 
> OPENR, unit, filename, /GET_LUN
>  
>   cursor here
>  
> CLOSE, unit
> FREE_LUN, unit

Indeed, I see I shall add a "how do i create a new snippet/template?" section 
in the help.

I don't know the filetype your snippet is for, let's say it's "foobar".

Create a "template/foobar" directory under the vimfiles/ directory in your 
$HOME (%HOMEDRIVE%%HOMEPATH% in windows).

In your $HOME/vimfiles/template/foobar, create a file named openr.template, it 
should get filed with default mu-template boilerplate settings.

Then, add what you want in your template file. If you keep the default

VimL: let s:marker_open  = '<+'
VimL: let s:marker_close = '+>'

Your can define placeholders with "<++>", or "<+placeholdername+>". It's even 
possible to accept parameters that can be injected from other snippets, or 
programmatically. (see :h s:Params()).

So, I guess, your template would look like:

VimL: let s:marker_open  = '<+'
VimL: let s:marker_close = '+>'
OPENR, <+unit+>, <+filename+>, /GET_LUN

<+cursor here+>
   
CLOSE, <+unit+>
FREE_LUN, <+unit+>



NB: I've simplified the explanation regarding the exact directory where you 
could put your new template files. see :h MuT-paths-override

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Create Autocompletion snippets for Custom Code

2016-08-23 Thread Luc Hermitte
Hi

> Is it possible to create your own autocompletion snippets using Vim
> functionalities or plugin? I have several custom code that I would
> like to create snippet for. I am using GVim on Windows. Most of
> existing autocomplete plugins like NeoComplete or YouCompleteMe etc
> do not work well on Windows. I am looking for something Vim native
> to do this.

There exist several template expander plugins that work on Window. mu-template 
is one of them. It's indeed 100% native (i.e. written only in viml).
-> https://github.com/LucHermitte/mu-template

If you want a smart completion, its internal completion function is available 
in lh-vim-lib
https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/icomplete.vim#L136
(it has been inspired from YCM equivalent feature ; see 
http://vi.stackexchange.com/questions/5820/dynamic-completion regarding its 
birth)

You'll find examples of use within mu-template code base and in the 
accompanying documentation.

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Use Case survey for C developers power tools plugin

2016-07-18 Thread Luc Hermitte
Hi,

> Our startup is developing power tools for C developers that will be
> available as a Vim plugin.
> 
> We plan to provide support for common refactorings (Rename, Extract
> Function, Extract Local, Change Message Signature, etc.,), automatic
> and smart code completion that is context-sensitive, quick fixes,
> etc.
> 
> We have created an infrastructure to support many syntax-aware and
> semantics-aware features.
> We want to know from the C developers (and hopefully future consumers
> of our plugin) about features that you would love to have.  This
> will help us make a better tool for the Vim+C developer community.

Discl.: 
- I don't really care about C. However, I care a lot about C++. 
- I've started years ago a generic refactoring suite built upon ctags poor 
understanding of C++.
https://github.com/LucHermitte/vim-refactor
- Regarding quickfix, I already have almost everything that I need 
(https://github.com/LucHermitte/vim-build-tools-wrapper)

Today, the main refactoring I miss is /function extraction/. I have a ersatz 
that doesn't work as well as I would like.
One of the main issue comes from ctags poor understanding of C++: it's quite 
difficult to list properly all local variables and types. I know I could do 
things correctly thanks to clang, but I don't really have the time to do it.
Note that it'll be quite important to be able to specify how out and in/out 
data are exchanged (reference parameter, returned values (tuples, struct...), 
attribute, and so on), and how arguments could be bound to parameters.

In all cases, I'd like the tool to respect the current project coding style 
(Note that I may open several windows/buffers with different coding styles. By 
/coding style/ I mean: naming policy (I may also have a naming policy for 
parameters and/or local variables), indentation, brackets placement, "const" 
placement (-> "T const&" VS "const T &"), ... I may also want the extraction to 
follow Almost Auto Policy if C++11 is detected.

Regarding smart code completion, we already have YouCompleteMe. My biggest 
issues with it are:
- It's quite difficult to have a configuration with is project specific.
- It doesn't support correctly code navigation (because code indexing is 
restricted to the current compilation unit) -- which isn't its main purpose, we 
have to admit.
- When its server crashes on a code base, it becomes completely impossible to 
use.


Good luck for your project,

-- 
Luc Hermitte 

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Make auto-completion insert multi-line text at one selection

2016-05-08 Thread Luc Hermitte
Hi

- Mail original -
> It seems the auto-completion feature does not allow multi-line text
> to be inserted at this point:
> [...]

> Can someone familiar with the implementation of Vim tell whether the
> custom-completion feature can be enhanced to become a general UI
> feature for user selection? The most useful IMHO would be:
> 
>   *. Allow normal mode invocation
> 
>   *. Pass the selection as a return value, instead of inserting it to
>   the current buffer

I provide a function in lh-vim-lib (1) that permits to define advanced 
completions. I use it in mu-template (2). The idea is to register a callback 
that is executed when the completion is validated -- as it's a callback, 
nothing is necessarily expanded. It's up to the callback function to decide 
what must be done.

Normal mode completion is not that complex. You just need to play with :normal, 
and possibly with :exe ":normal ...".

(1) lh#icomplete#new() and lh#icomplete#new_on()
https://github.com/LucHermitte/lh-vim-lib

(2) https://github.com/LucHermitte/mu-template

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: How to detect the file type in vimrc?

2016-04-07 Thread Luc Hermitte
Hi,

> Indeed, I'm pretty sure the file itself hasn't been read yet when
> reading the .vimrc, but I may be wrong about that.

Worse. When you open a second or a third file, the .vimrc isn't read anymore.

.vimrc settings are meant to be global settings that can apply to anything.

When we want dedicated settings, this is best done in ftplugins (when the 
variability is over the filetype). If it's over projects/directories, check for 
one of the local_vimrc plugins.
Otherwise, there are indeed autocommands, but they'll clutter the .vimrc with 
non global stuff.

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Revert keys values in dict

2016-04-01 Thread Luc Hermitte
Hi,

> Hi,
> 
> I would like to make values become keys in this dict, is it possible
> in one simple command  ?
> 
> let mydict={'':'"', '':'&', '':"'", '':'<'}


For instance, 
   :echo map(copy(mydict), '{v:val : v:key}') 

doesn't permit to build a new dictionary from scratch

However, with a dirty hack, it becomes possible to do this with a 
almost-oneliner:

   :let d2 = {}
   :call map(copy(mydict), 'extend(d2, {v:val : v:key})')
   :echo d2


HTH,
-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Replace c cast to c++ style cast

2016-02-28 Thread Luc Hermitte
Hi Jorge, 

> Luc, I did install your library but the mapping provided ,,sc didn't
> do anything for me.

You have to select the C cast expression before hitting ,,sc. Depending on your 
leaderleader, it could be something else.

> I did have an error when entering a c++ buffer after loading the
> plugin with VAM, something like:
> 
> line 39:
> E227: mapping already exists for <80>^D

Unfortunately, I have to idea which key <80> refers to. It's line 39 from 
which file? Once you identify it you should be able to provide another 
keybinding in your .vimrc (or may be in a ftplugin with higher priority)


> I am not sure this is the reason I cannot use the mapping provided in
> your plugin.
> 
> 
> I did write a function and mapping that for now should suit my needs:

It could be simpler: 

" From ftplugin/cpp/cpp_snippets.vim
vnoremap   sc
  \ <c-\>:'<,'>call ConvertToCPPCast('static_cast')
nmap   sc 
viwsc


function! s:ConvertToCPPCast(cast_type) abort
  " Extract text to convert
  let save_a = @a
  silent normal! gv"ay
  " Strip the possible brackets around the expression
  " matchlist seems to cause an odd error on multiline C cast expressions: it
  " have the fucntion called again.
  let [all, type, expr ; tail] = matchlist(@a,  
'\v^\(\_s*(.{-})\_s*\)\_s*(.{-})\_s*$')
  let expr = substitute(expr, '\v^\(\s*(.{-})\s*\)$', '\1', '')
  "
  " Build the C++-casting from the C casting
  let new_cast = a:cast_type.'<'.type.'>('.expr.')'
  " Do the replacement
  silent exe "normal! gvs".new_cast."\"
  let @a = save_a
endfunction


-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: Replace c cast to c++ style cast

2016-02-26 Thread Luc Hermitte
Hi,

> There is a switch in g++ that warns about c style casts.
> I will try to fix those but there are plenty in the project where I
> am working.
> 
> Can someone recommend a function that would allow to do this in vim?

In lh-cpp (*), I have 3 mappings that transform C casts into C++ casts -- and 6 
more to cast an expression. 

This has to be done manually: you'll have to know if you want a const_cast, a 
static_cast, or a reinterpret_cast. As Dominique said, it can't really be done 
automatically. May be, clang could automate many things, but it won't be able 
to know whether you want to downcast with a dynamic_cast or with a static_cast?

(*) https://github.com/LucHermitte/lh-cpp

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: How to complete popup as I type

2016-01-12 Thread Luc Hermitte
Hi,


> I am trying to use complete() in vim so that it reads the value as
> well.
> 
> For example, from vim's complete() example,
> [...]
> 
> if I type  I will get all the months as a pop up. Now, what I
> want is, if I type "J", only January, June and July will be shown,
> "Ju" will give June and July, and so on.
> 
> I read the vim-doc, and tried complete_check, but that's not.
> 
> Also, I have tried to use omnicomplete example E839 in vimdoc, but I
> cant properly call it, always getting invalid argument error.
> 
> Please suggest me the the preferred method of menu with completion as
> I type, and how to use that.

Last December, I tried to follow the documentation to implement a dynamic 
completion as well.
Alas I didn't succeed. I suspect either a bug in vim or an invalid 
documentation regarding completion "third mode" and so on.

Correct me if I'm wrong.


In the end I've "found" a workaround. It consists in:
- listening to CursorMoveI to detect the end of the completion mode (and to 
restart the completion mode otherwise) ;
- and in using feedkey to force the restart of the completion mode after each 
key typed.

You'll find more complete code and explanations on 
http://vi.stackexchange.com/questions/5820/dynamic-completion/5935#5935

HTH,

-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Dynamic completion

2015-12-10 Thread Luc Hermitte
Hi

I'm trying to enhance an old completion function. I'd like it to update the 
choices displayed in the popup menu as I type new characters

My completion function is

  function! lh#icomplete#ecm(findstart, base) abort
if a:findstart
  let l = getline('.')
  let startcol = match(l[0:col('.')-1], '\v\S+$')
  if startcol == -1
let startcol = col('.')-1
  endif
  " let g:debug+= ["findstart(".a:base.") -> ".(startcol)]
  return startcol
else
  " let g:debug += ["matching(".a:base.")"]
  let words = ['un', 'deux', 'trois', 'trente-deux', 'unité']
  let matching = filter(words, 'v:val =~ a:base')
  " return { 'words' : words}
  return { 'words' : words, 'refresh' : 'always'}
endif
  endfunction


That I use with
  :set completefunc=lh#icomplete#ecm
and
  :inoremap µ 


>From my understanding of the documentation, the fact I use , I go into 
>the "third state" (according to |ins-completion-menu|), and when I type "any 
>printable, non-white character" I should be able to "Add this character and 
>reduce the number of matches."

When I type in insert mode "uµ", the completion menu pops-up as expected.
Alas when I type 'x' (just after the 'µ'), I'm out of completion mode and "ux" 
is what I have in mu buffer.

What did I do wrong or missed in the documentation?

NB: I've seen that without "refresh=always", result are filtered, except I'd 
like to call the function again in order to apply a custom filter.

Regards,

(Just in case, I'm using gvim 7.4-908)
-- 
Luc Hermitte

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: test wrapping for coders

2015-12-06 Thread Luc Hermitte
Hi

> Is there a quick way to wrap word with a pair of the following '',
> "", (), {}, [] ? When I'm coding and my cursor is on a word it would
> be nice to be able to quickly press a key or two and the keyboard
> and get that word wrapped on a set of the above. Thanks.


lh-brackets combines surrounding and pair-insertion. Surrounding with a pair of 
bracket-like characters is meant to be ergonomic. You want to surround with 
'()'? Just hit '(' -- defaults can be overridden, extended, ...
https://github.com/LucHermitte/lh-brackets

surround plugin, also provides a surrounding feature. This time the keybindings 
is more in the line of vim way of doing things regarding operator-pending 
mappings: ysiw) (if I'm not mistaken)
https://github.com/tpope/vim-surround

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: substitute with list content

2011-07-20 Thread Luc Hermitte
Hello,

Chen San wrote:

 i have saw some usages in such a form:
 
 let i=1 | g/foo/s//\=blah_.i/ | let i=i+1
 
 then my question is, what if i wanna substitute something with a list,
 such as ['one','two','three']

Sometimes ago, I wrote a :RotateSubstitute command that should answer your need:

http://code.google.com/p/lh-vim/source/browse/misc/trunk/plugin/rotate_substitute.vim

:%RotateSu/foo/one/two/three

The simple version without backref support had been given on SO:
http://stackoverflow.com/questions/1809571/how-do-i-substitute-from-a-list-of-strings-in-vim/1809780#1809780

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Go to start/end of a method in C++?

2011-07-08 Thread Luc Hermitte
Hello,

- Toby Walsh wrote :

 First post to the list so be easy on me. I'm trying to write some
 functions to automate my commenting process in C++. Reading the help,
 I would like to use the motion commands ]m, ]M, [m and/or [M for
 jumping around to starts and ends of function definitions.

The easiest way is to play with a ctags base that uses line numbers.
That's what I use in my refactoring plugin to identify the begin/end of 
functions.

Given the current line, the function lh#dev#find_function_boudaries(line_nb) 
will return various information.
It's from lh#dev, a library plugin dedicated to code analysis.
- http://code.google.com/p/lh-vim/source/browse/#svn%2Fdev%2Ftrunk

By looking into the function code, you'll see the list of the functions from 
the current file. Then, you'll just have to use it to navigate between all 
functions.

BTW, I also already have a command (:DOX) that builds the doxygen comment for a 
function given its signature:
- parameters (in/out)
- return type
- exception specifications
- ...
 
Install lh-cpp for this feature.
http://code.google.com/p/lh-vim/wiki/lhCpp_Doxygen

 
HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Go to start/end of a method in C++?

2011-07-08 Thread Luc Hermitte

- Luc Hermitte wrote :

 - Toby Walsh wrote :
 
  First post to the list so be easy on me. I'm trying to write some
  functions to automate my commenting process in C++. Reading the
  help, I would like to use the motion commands ]m, ]M, [m and/or 
  [M for jumping around to starts and ends of function definitions.
 
 The easiest way is to play with a ctags base that uses line numbers.
 That's what I use in my refactoring plugin to identify the begin/end
 of functions.
 [...]

As I have been missing these four [m, ]m, [M and ]M to find method only, for 
quite some time now, I've just implemented them.

http://code.google.com/p/lh-vim/source/browse/cpp/trunk/ftplugin/c/c_navigate_functions.vim

This will require lh-dev and lh-tag, and lh-vim-lib.
If you don't want the whole lh-cpp package, you can install lh-dev via 
vim-addon-manager (which will install lh-tag and lh-vim-lib in turn), and just 
download the new ftplugin.


NB: regarding your need, you'd better play lh#dev#star_tag_session() + filter 
(see lh-dev functions) to obtain the list of functions in your file, and their 
respective line numbers -- and pass them to the signature analyser: 
lh#dev#function#*()

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Conditionally generated templates

2011-06-24 Thread Luc Hermitte
Hello,

Tim Roberts wrote :
 I write php using an MVC framework, and I'd love to be able to
 conditionally generate some of my new file content.
 
 The main ones would be
vim app/controllers/projects_controller.php
 
 Should produce:
 
 ?php
 class ProjectsController extends AppController {
  
 }

With mu-template, you'll need a template-file named 
~/.vim/after/template/php.vim that contains
-- % ---
VimL: hint: php class file for Tim Roberts' project
VimL: let s:value_start = '¡'
VimL: let s:value_end   = s:value_start
VimL: let s:marker_open  = '+'
VimL: let s:marker_close = '+'
VimL: let s:filename = s:path_from_root(expand('%:p'))
VimL: let s:parts=split(s:filename,'/')
VimL: let s:class=matchstr(s:parts[-1], '.*\ze\.')
VimL: let s:class=lh#dev#naming#to_upper_camel_case(s:class)
VimL: let s:base=join(s:parts[0:-2],'_')
VimL: let s:base=lh#dev#naming#to_upper_camel_case(s:base)
?php class ¡s:class¡ extends ¡s:base¡ {
++
}
-- % ---
The file is best saved in utf-8 encoding.

mu-template [http://code.google.com/p/lh-vim/wiki/muTemplate] has several 
dependencies listed on the wiki (lh-vim-lib, and lh-brackets) (If you use 
vim-addon-manager, it will be managed for you automatically).

The template-file itself has two dependencies.
* First it requires b:sources_root to be set before you open the file. AFAIK, 
only my version local_vimrc can ensures this: 
http://code.google.com/p/lh-vim/source/browse/misc/trunk/plugin/local_vimrc.vim

* Then it requires lh-dev function: to_upper_camel_case()
Its definition is really simple (if you prefer not to install this undocumented 
plugin): 
http://code.google.com/p/lh-vim/source/browse/dev/trunk/autoload/lh/dev/naming.vim#56

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Aw: Re: Conditionally generated templates

2011-06-24 Thread Luc Hermitte

- lith wrote:

 With mu-template, you'll need a template-file named
 ~/.vim/after/template/php.vim that contains
 For comparison, here is Luc's template converted to tskeleton:

Interesting. This is really neat.
I doubt I can add the before/ and after/ sections, but it gave me an idea 
to simplify the syntax about expanding variables from the placeholders.

 tskel:before
 let s:filename = expand('%:p')

With mu-template, I had to add a hook in order to load project-specific 
settings (defined with plugins like local_vimrc) before the newbuffer event is 
trigerred. The typical application is to define project root-directory, to 
deduce header guards in C/C++, or the base class name in OP's case.

Out of curiosity, does tskeleton support template-file inclusions ? Because of 
the before/after sections, I'd say no -- as they imply some complexity if we 
want to support things like a switch-snippet that loads the case-snippet for 
every value from an enumeration. (that's not impossible, but that requires a 
lot of context pushespops)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Vim dsitribution for C++?

2011-05-23 Thread Luc Hermitte
Hello,

Antonio Recio wrote:

 Do you know some distribution of vim for C++ development with the
 recommended plugins? Something like http://spf13.com/project/spf13-vim
 or Ex-Vim http://code.google.com/p/exvim/

I have several plugins that I use intensively for C++, but no ready to use 
environment. (see the first link in my signature)

One of the main reason is that I use non-hype plugins, mu-template being the 
main one.

PS: I've tried to publish VAM files, but they are all bugged. I have to find 
time to fix them (and publish the latest changes also)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Vim Scripting Mode/Plugin

2011-02-18 Thread Luc Hermitte
Hello,

Nathan Neff wrote:

 I know there's some C, Java, Perl and Bash vim plugins.
 
 Are there any plugins that help with writing Vim scripts?

Over the years, I have developed a few things in that area:

- some smart-snippets (that won't expand within comments/string) and other 
surrounding stuff:
  http://code.google.com/p/lh-vim/source/browse/misc/trunk/ftplugin/vim_set.vim
  This requires lh-map-tools: http://code.google.com/p/lh-vim/wiki/lhBrackets
  which in turn requires lh-vim-lib: 
http://code.google.com/p/lh-vim/wiki/lhVimLib (like most my other plugins)

- template-files for muTemplate that expand into what I've come to consider to 
be good practices for plain-plugins, ft-plugins, directories-local-plugins, and 
autoload-plugins (the kind of script is automatically detected) (nothing 
specific is done for indent/syntax/folding/... files)
  http://code.google.com/p/lh-vim/wiki/muTemplate#Vim (which also requires 
lh-map-tools and lh-vim-lib)
  A few other snippets for vim are shipped with mu-template

- 
http://code.google.com/p/lh-vim/source/browse/misc/trunk/ftplugin/vim/vim_maintain.vim
  that defines :Reload that knows how to source (ft)plugins protected by the 
anti-reinclusion guards automatically generated by mu-template template-files.
  and that overrides n_K and v_K to call :h with the right vim function-name 
(scoped#function#names are a bit tricky if isk is not properly set)

- 
http://code.google.com/p/lh-vim/source/browse/misc/trunk/ftplugin/vim/vim_refactor.vim
  is an experimental plugin that will eventually move functions to 
autoload-plugins, with their dependent functions detected.
  (I don't remember whether the version committed already requires lh-vim-dev 
(various kind-of-polymorphic functions related to the analysis of source-code, 
and its transformation) nor lh-tags)

- A framework to Unit Test vim functions: 
  http://code.google.com/p/lh-vim/wiki/UT

- A generic refactoring plugin that also handles viml:
  http://code.google.com/p/lh-vim/wiki/lhRefactor


HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: string type in vim script language

2011-02-01 Thread Luc Hermitte
Hello,

shuda Li wrote:

 Thank you every one!
 
 Briefly conclude:
 
 let filename =  expand(%:t:r).'.cpp'

Hmm.. Did you see the Alternate plugin (#31) ? And IIRC, there exist another 
plugin that does the same job.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Omni Complete

2011-01-20 Thread Luc Hermitte
Hello,

Marc Weber marco-owe...@gmx.de wrote:

 Excerpts from Bryan Hunt's message of Wed Jan 19 01:30:18 +0100 2011:
  A question also, if I may. Is snipmate or are any of the vim
  template approaches capable of referencing variables, the base 
  file name, for example.
 Yes. snipmate: `any-vim-code` See its documentation.
 I do no longer recall about xptemplate. I'm pretty sure it has
 something similar.

Several template expander plugins have this feature.
mu-template templates even support loops, recursion, and parameters since its 
last version -- e.g. 
http://code.google.com/p/lh-vim/wiki/lhCpp_Enums#switch-case_generation
(The syntax is a bit awkward though -- 
http://code.google.com/p/lh-vim/source/browse/mu-template/trunk/after/template/c/switch.template).

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Getting length of the the selection

2010-12-13 Thread Luc Hermitte
Hello,

Andres Perera wrote:

 On Sun, Dec 12, 2010 at 11:35 PM, C K Kashyap ckkash...@gmail.com
 wrote:
 
  I have a set of lines like this -
 
  char str1 = hello;
  char str2 = printer;
 
  and I'd like to generate -
 
  char str1 = hello;
  char str1_arr[5];
  char str2 = printer;
  char str2_arr[7];

As your are writing in C, why aren't you directly writing:
   char str1[] = hello;
The compiler will automatically have str1 contain 6 characters.

Other solution (for a mapping):
   :s#char\s\+\(\S\+\)\s*=\s*\(.*\)\s*\zs;#\=\nchar 
.submatch(1)._arr[.len(submatch(2)).];#
(which will not count another character for the 0-terminal)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Example code to wrap predefined text around selected text

2010-12-03 Thread Luc Hermitte
Hello,

Harry Putnam wrote :
 Can anyone show an example of how to do this:
 
 I want to wrap this:
 [...]
 Around the selected text... that is, select some text and press a key
 combo ... voila... its no surrounded by:
   # [HP 101202_15:55:07 
 
   # ] 
 
 Over the yrs I've acquired a fairly lengthy .vimrc but coding
 something like that is clear out of my skil set.

I've written a few functions to do surround anything: InsertAroundVisual() and 
Surround()
   http://code.google.com/p/lh-vim/wiki/lhBrackets#The_VimL_library

And I suspect there is a vim tip on the subject.

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


manipulation of multi-byte strings

2010-11-04 Thread Luc Hermitte
Hello,

I'm in the process on upgrading my scripts to support multi-byte strings.
I've identified a few needs for now:
- a mbyte strlen
- a get-at(pos) operator

Regarding string length, |strlen()| recommends to play with substitute(), 
however I see strwidth() that seems to do the work, is there a reason that this 
is not the recommended way ?

Regarding [] alternative, matchstr('.\{'.pos.'}\zs.\ze') does the job (for pos 
 0). Is there a better way to proceed ?

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Enabling/disabling abbreviations

2010-09-20 Thread Luc Hermitte
Hello,

Andre Majorel wrote:

 What's the best approach to enabling/disabling a large subset
 (thousands) of the abbreviations ? Use expr and turn them
 all into functions that are no-ops when some global variable is
 set ?

The badly named Triggers.vim plugin I wrote ages ago answers this need:
- http://code.google.com/p/lh-vim/source/browse/misc/trunk/plugin/Triggers.vim
(documented there: http://hermitte.free.fr/vim/general.php#expl_triggers)

You'll require system_tools and quite likely lh-vim-lib to make it work.

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Generating html documentation with hlink to jump easily

2010-08-30 Thread Luc Hermitte
Hello,

epanda wrote:

 I know the html converter into Gvim but I would like to convert my
 plugin help documentation into html that can take care about hlink.

Ages ago, I patched a perl script that runs the HTML converter in vim, and then 
add all the hyperlinks that make sense (plus a few other things).
I haven't run it for a long time, so I don't know how it will do with vim 
latest versions.

- http://hermitte.free.fr/vim/ressources/tools/ (don't forget the perl module 
VimDetect.pm)

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: vim script meta programming trouble

2010-07-09 Thread Luc Hermitte
Hello,

gabriel wrote:

 I wrote this function that generates toggle functions:

[...]

 I would like to make a version that works under 6.3 but I can't quite
 figure it out. I can't actually figure out why it doesn't work in 6.3
 short of the fact that I can't seam to define any functions a all via
 execute under vim 6.3

Ages ago, I wrote this mis-named plugin that generates toggle functions for 
almost anything (set-variables, mappings, abbreviations, etc)
  http://code.google.com/p/lh-vim/source/browse/misc/trunk/plugin/Triggers.vim

The first versions are still available on SF:
  http://www.vim.org/scripts/script.php?script_id=48

And more recently (it's relative), I came up with a way to cycle a variable 
among a list of possible values:
  lh#menu#def_toggle_item -  
http://code.google.com/p/lh-vim/wiki/lhVimLib#Menus_related_functions
  example of use - 
http://code.google.com/p/lh-vim/source/browse/vim-lib/trunk/tests/lh/test-toggle-menu.vim

(it's vim7 only though)


PS: upgrading your vim version is also a good idea. I systematically install a 
recent version of vim in my $HOME -- by compiling its sources.
 
-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


diff and synchronisation

2010-06-18 Thread Luc Hermitte
Hello,

I was wondering if there was a way to know the set of matching lines when in 
diff mode (after a ]c)

After a ]c (/[c), I've first tried to go from one window to the other, but then 
the cursor is not on the same lines in the two (or more) synched windows.

I've quickly discarded any solution where I could directly play with ln = 
line('.') ; focus on next window ; l2 = getline(ln) as the diffed buffers 
won't have the same number of lines.

Then, I've noticed that both windows have their first line synchronized. I 
though at first I could directly use  ln = winline() ; ^Ww ; exe 'normal 
'.ln.'H'. Unfortunately, winline() counts the fake lines than are introduced 
by diff-mode, while H works on actual lines, ignoring the fake ones.

So, is there a solution other than iteratively moving down until both winline() 
results are equal ?


NB: I'm trying to solve this puzzle: 
http://superuser.com/questions/145940/vimdiff-jump-to-next-difference-inside-line
The current, incomplete and not working code is:
-- % -
nnoremap expr silent F3   (diff ? ]c:call \sidNextDiff()\cr : 
:cn\cr)

function! s:NextDiff()
  if ! diffopt =~ 'filler' | return | endif

  let ignore_blanks = diffopt =~ 'iwhite'

   Assert: called just after a ]c or a [c
   Forces the cursors to be synchronized in all synced windows
   let diff_l = line()
  let w_l = winline()  problematic with ignored lines (from diff...)
  echomsg w_l.'|'.line('.').'|'.getline('.')

  
  let lines = {}
  windo if diff | exe 'normal! '.w_l.' H' | let lines[winnr()]=getline('.') | 
endif
echomsg string(lines)
  if len(lines)  2 | return | endif

  let indices = repeat([0], len(lines))
  let tLines = values(lines)
  let found = 0
  while ! found
let c = ''
let next_idx = []
let i = 0
while i != len(indices)
  let crt_line = tLines[i]
  let n = indices[i]
  let c2 = (len(crt_line) == n) ? 'EOL' : crt_line[n]
  if empty(c) 
let c = c2
  endif

   checks match
  let n += 1
  if c =~ '\s'
if (c2 != c) || (ignore_blanks  c2 !~ '\s')
  let found = 1
  break
else  advance
  while ignore_blanks  (n == len(crt_line) || crt_line[n] =~ '\s')
let n += 1
  endwhile
endif
  else
if c2 != c
  let found = 1
  break
endif
  endif
  let next_idx += [n]

  let i += 1
endwhile
if found | break | endif

let indices = next_idx
  endwhile

   now goto the right column
  echomsg string(indices)
endfunction
-- % -

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Problem setting runtimepath in vimrc

2010-06-04 Thread Luc Hermitte
John Little wrote :

 On Jun 4, 3:23 am, Luc Hermitte hermi...@free.fr wrote:
 
  It looks like you should be using:
      let rtp=$MYPATH.','.rtp
 
 or more plainly
 
 set rtp^=$MYPATH

Indeed, that's much better!
I didn't know :set^=

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Problem setting runtimepath in vimrc

2010-06-03 Thread Luc Hermitte
Hello,

Pablo Giménez wrote:

 I have in my $HOME/.vimrc the next statetement to set the runtime
 path:
 set runtimepath=$MYPATH, $VIMRUNTIME

It looks like you should be using:
let rtp=$MYPATH.','.rtp

rtp default value is not $VIMRUNTIME, see :h 'rtp'

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: Determine how many windows are on screen

2010-05-28 Thread Luc Hermitte
Hello,

David Fishburn wrote :

 I am trying to determine via VimScript how many windows are on the 
 screen at the moment.
 More specifically, I am trying to determine if a user just opened Vim
 and they are sitting at the [No Name] buffer.

 [...]
 
 Suggestions?

I use the following: 
  http://code.google.com/p/lh-vim/source/browse/misc/trunk/vimrc_core.vim#516

If the len of the current buffer is null, and that there only one empty line, 
then I consider I'm sitting at this [No Name] buffer.
It also works after a :new.

HTH,

PS: you can also play with: 
   :echo len(filter(map(lh#buffer#list(), 'bufwinnr(v:val)'), 'v:val != -1'))
to obtain the list of opened windows and their number. But regarding what you 
are looking for, this is a very complex solution.
[lh#buffer#list() comes from lh-vim-lib, see my signature)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


ANN: refactor v0.1.0 released

2010-05-25 Thread Luc Hermitte
Hello,

I've just released a first version of a generic refactoring suite for Vim.
   http://code.google.com/p/lh-vim/wiki/lhRefactor

Today the following refactorings are supported:
- extract variable (on v_CTRL-X_v)
- extract type (on v_CTRL-X-t)
- and extract function (on v_CTRL-X_f)

This version mainly focuses on the languages I'm working with on a daily basis, 
i.e. C++ (and by extension C), and VimL. However, it can be extended quite 
easily to other languages -- some customizations are also provided for Pascal 
(I've an interactive extract function), bash and perl. Plenty examples are 
available in the source code, and in the documentation.


This suite requires the following:
- lh-vim-lib v2.2.0: my library of VimL functions
- and lh-map-tools v1.0.0: my bracketing system, or more precisely the 
placeholder subsystem.


Future developments are likely to:
- Propose a simple way to use mu-template from a hook, and exchange variables 
with it.
- Propose other refactorings (I have a few ideas regarding a move class 
methods around, extract interfaces, etc based on the :Override feature 
I've already implemented in lh-cpp).
- Have extract function determine automagically the parameters of the 
extracted function.
- And may be to provide customized hooks for other languages (don't hesitate to 
participate).

Enjoy, and of course comments are welcomed.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: insert a new line at the begin of a file

2010-05-22 Thread Luc Hermitte
Hello,

ranjith kumar wrote :
  Can someone tell me how add blow 2 lines at the begining of a file
 using vim substitution command (like 1s/*/namespace f/ or
 %s/*/namespace f/)'
 line 1:  namespace family
 line 2 : {
 
 
 also at the end of the file I have to add  a new line containing '}]
 at the end of the file.

I think you'd better have a look at template-files expanders.
You have a non exhaustive list on vimtips:
   http://vim.wikia.com/wiki/Category:Automated_Text_Insertion

In case I haven't fully understood your need, and that you have a pre-existing 
file and want to surround its contents by namespace { ...}, there also exist 
a few solutions that does that.
The keyword (for vim.wikia, vim.org, google, etc) is surround. Regarding 
namespace and C++, I have my suite that provides a ,ns mapping to enclose the 
visual selection within a namespace.
   http://code.google.com/p/lh-vim/wiki/lhCpp
(for once the files have been committed recently, lh-cpp and mu-template need 
to be obtained from svn, lh-vim and searchinruntime can be obtained in the 
download section.)

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: a.vim wildcards in search path?

2010-05-20 Thread Luc Hermitte
Hello,

Keffin Barnaby ... wrote :

 I'm using the a.vim[1] plugin [...]
 
 I tried using a wildcard by adding sfr:../include/*,sfr:../../src to
 g:alternateSearchPath. With this setup, switching from test.h to
 test.cpp is standard stuff and works fine, but going from test.cpp 
 to test.h works ONLY when I have previously switched from test.h to 
 test.cpp.

I have a similar directories architecture. However I have had used the 
following for quite some time now:
  let g:alternateSearchPath = 'reg:#/src/cpp#/inc#,reg:#/inc#/src/cpp#'

I also remember I had a few issues with pathnames. In the end I've patched 
a.vim for my personal use, I won't guaranty it will fix your issue though (I've 
just tested that I'm able to find the file with :AV from only the .cpp opened 
with as long as it already exist). The result is available here: 
  http://code.google.com/p/lh-vim/source/browse/cpp/trunk/after/plugin/a.vim

NB: along the process, I've introduced a dependency to a library I'm 
maintaining, only the following file is requested for this patched version of 
a.vim:
   
http://code.google.com/p/lh-vim/source/browse/vim-lib/trunk/autoload/lh/path.vim

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: a.vim plugin issues

2010-05-19 Thread Luc Hermitte
Hello,

[discl.: I'm going through my email archives, I don't know if this is still a 
problem for you]

Pavel Shevaev ... wrote :

 Folks, I use a.vim plugin(Alternate Files quickly (.c -- .h etc))
 and I really enjoy it, the only issue I don't like about it is the
 fact it makes wrong guesses from time to time.
 
 [...] Can I enforce a.vim search for
 alternative file in the same directory where the currently 
 opened file resides and never use files in the buffer list?

I also had a few issues with the way a.vim manages directories.
In the end I patched it: 
http://code.google.com/p/lh-vim/source/browse/cpp/trunk/after/plugin/a.vim
You can try it to see if it solves your issue as well.

(However, I introduced a dependencies to a function of mine in lh-vim-lib: 
http://code.google.com/p/lh-vim/wiki/lhVimLib)



PS: I haven't committed all my scripts _yet_ to match the latest functions 
naming policy in lh-vim-lib. Prefer _recent_ vimball archives over other 
solutions (svn/ deprecated vbas) in case my other scripts sound appealing.
-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
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


Re: visual_studio.vim

2010-01-18 Thread Luc Hermitte
Hello,

Ben Fritz fritzophre...@gmail.com wrote:

 On Jan 15, 2:31 pm, Max max.dyckh...@gmail.com wrote:
  Does anyone know if it would be possible to make 
  a non-blocking build command?

 
 In general no, Vim does not support non-blocking commands.
 
 In this case, you *might* be able to do something like ':!start
 {build command}  {error file}  vim --remote-send :cfile {error file}
 CR' instead of :make but I don't know whether this will succeed
 or not.

That's what I've used in BTH [1] -- that only works under unix, and that 
actually do a few more thing other than a :cfile. 

IIRC, Marc Weber wrote another plugin for background compilation that works 
under Windows as well.

[1] http://code.google.com/p/lh-vim/source/browse/#svn/BTW/trunk

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/
-- 
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php

Re: visual_studio.vim

2010-01-18 Thread Luc Hermitte

Max Dyckhoff max.dyckh...@gmail.com wrote:

 A cursory search turns up nothing about that, sadly.
 
 In your experience, which part of Ben Fritz's solution didn't work?  
 I'm away from the office today so I'll be unable to try it til  
 Tuesday, but thanks for the suggestions; I'll let you know what
 happens.

Otherwise, I was unable to background-execute my perl script with start from 
my win32-gvim. It was quite a long time ago, I don't remember what were the 
various ways I tried back then. Hence I cannot tell without testing it whether 
Ben's solution will actually work.

The background compilation in BTH exists the way it does in order to do a few 
other things (related to _background_ compilation):
- it removes the temporary file once read,
- it executes hooks of the quickfix windows if any where defined (syntax 
coloring)
- it permits to configure the desired maximum size for the qf window.


 On Jan 18, 2010, at 7:33 AM, Luc Hermitte hermi...@free.fr wrote:
[...]
  In general no, Vim does not support non-blocking commands.
 
  In this case, you *might* be able to do something like ':!start
  {build command}  {error file}  vim --remote-send :cfile {error 
  file} CR' instead of :make but I don't know whether this will
  succeed or not.
 
  That's what I've used in BTH [1] -- that only works under unix, and 
  that actually do a few more thing other than a :cfile.
[...]

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/
-- 
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php

Re: How to Create a pick (select) list

2010-01-11 Thread Luc Hermitte
Hello,

Tom Link micat...@gmail.com wrote :

   Is it possible to create a pick list from an internal array?
  If you specify in more details, what you want
 [...]
 
 There are other plugins that achieve similar goals slightly
 differently (some of them make use of vim's completion menu, some
 don't).

Indeed.
I have a few functions that help to define asynchronous pick lists. It is not 
really simple to use as there is a lot of things to specify: the list of items, 
and the title/question of course, but also the callback to execute, whether 
multi-selection is supported and so on.

In the past I gave a quick tour of the library: 
http://www.mail-archive.com/vim_use@googlegroups.com/msg04606.html

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/
-- 
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php

Re: Detect when a return follow an if instruction without bracket

2009-11-27 Thread Luc Hermitte
Hello,

epanda callingel...@hotmail.fr a écrit :

 if (condition1
   condition 3 )
 return

Wouldn't a )[[:blank_or_comment:]]return\ be enough ?
Of course it would match nonsense code like foo(42) return; or while (cond) 
return, but does it really matter?

In GotoImpl [1], I've implemented the [[:blank_or_comment:]] this way:
   \(\_s\|/\*.\{-}\*/\|//.*$\)*
(Hum ... oddly I did not use \_. instead of . in the second expression... I 
guess the pattern should be modified to use the \@ multi-items)

[1] http://code.google.com/p/lh-vim/wiki/lhCpp and more precisely: 
http://code.google.com/p/lh-vim/source/browse/cpp/trunk/autoload/lh/cpp/AnalysisLib_Function.vim#526

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php


Re: Detect when a return follow an if instruction without bracket

2009-11-27 Thread Luc Hermitte
Andy Wokula anw...@yahoo.de wrote:

  In GotoImpl [1], I've implemented the [[:blank_or_comment:]] this
 way:
 \(\_s\|/\*.\{-}\*/\|//.*$\)*
 
 Epanda, for a C-comment, the pattern
 \/\*\_.\{-}\*\/
 is simpler than what I gave you.
 
  (Hum ... oddly I did not use \_. instead of . in the second
  expression... I guess the pattern should be modified to use the \@
  multi-items)
 
 '\@' multi item?

:h /\...@!
:h /\...@=
:h /\@=
...

(I've never been able to make sense out of them)

  [1] http://code.google.com/p/lh-vim/wiki/lhCpp and more precisely:
 
 http://code.google.com/p/lh-vim/source/browse/cpp/trunk/autoload/lh/cpp/AnalysisLib_Function.vim#526
 
 Result:
 /)\%(\_s\|\/\*.\{-}\*\/\|\/\/.*$\)*return\
 
 Minor difference: it will match wrong code like
 
 )
 /* */ */
 return

Worse, with \_. instead of ., it will match
)
/* some comment */
g(42);
  }
  void g(int i) {
/* other comment  */
return i;
  }

Hence the need to play with \...@** patterns -- as we need to match:
  )
  /* somme comment
 on several lines */
  return 42;

 Alternative:
 /)\_s*\%(\%(\/\*.\{-}\*\/\|\/\/.*$\)\_s*\)*return\
 
 This way it's easier to restrict the number of comments:
 /)\_s*\%(\%(\/\*.\{-}\*\/\|\/\/.*$\)\_s*\)\{,5}return\

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

-- 
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php


Re: How to get directory list from script ?

2009-11-25 Thread Luc Hermitte

Hello,

Peter Marczis (NSN - HU/Budapest) peter.marc...@nsn.com wrote :
 I would like to write a vim script which reads into a list , the
 directory tree…
 how it is possible to get the subdirectories into a list ? (from PWD
 for example.)

You can also play with:
  echo filter(split(globpath(getcwd(), '**'), '\n'), 'isdirectory(v:val)')

It may not be the most efficient way, but it should do the trick.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: load key mappings with syntax file

2009-10-17 Thread Luc Hermitte

Hello,

MK halfcountp...@intergate.com wrote:

 is there anyway I could indicate in my .vimrc another rc file to load
 
 with certain syntax files, so I could use different key mappings and 
 such for different languages?

You are looking for ftplugins.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: jumping to start of function or class in C++

2009-10-08 Thread Luc Hermitte

Hello James,

James Kanze james.ka...@gmail.com :

 I'm currently having to deal with C++ code which uses the
 following coding conventions:
 [...]
 My problem is getting [[ and ]] to advance or go back to the
 next function (or class); the opening braces aren't always in
 column 1; [...] I rather suspect that some parsing of the C++
 itself will be necessary.
 [...]
 Does anyone know of any available solution?

The simplest solution will probably consist in assembling a regex from all 
the functions that ctags has seen in the current file. 

As unfortunately taglist() does not permit to select tags on field values, you 
may have a grep the relevant tags file in search of expand('%:t'), keep only 
the search commands, join them in a search pattern with \|, and finally search 
for the newly built pattern.

Another way will consist in parsing the code in search of (surrounding) pairs 
of brackets. A solution should possible for simple cases, but I'm afraid it 
won't be perfect.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: jumping to start of function or class in C++

2009-10-08 Thread Luc Hermitte

James Kanze james.ka...@gmail.com wrote :

 On Oct 8, 3:21 pm, Luc Hermitte hermi...@free.fr wrote:
  James Kanze james.ka...@gmail.com :
   I'm currently having to deal with C++ code which uses the
   following coding conventions:
   [...]
   My problem is getting [[ and ]] to advance or go back to the
   next function (or class); the opening braces aren't always in
   column 1; [...] I rather suspect that some parsing of the C++
   itself will be necessary.
   [...]
   Does anyone know of any available solution?
 
  The simplest solution will probably consist in assembling a
  regex from all the functions that ctags has seen in the
  current file.
 
 Which will still miss classes, I suppose (but it wouldn't be too
 difficult to add class, struct and union to the regex).
 I'll also have to install ctags, since it's not present on this
 machine.

All tags in ctags results have a kind: class, struct, union, function, 
prototype, ...
However, indeed you'll have to install ctags (which will grant you access to 
several features of my C++ ftplugin suite for vim ^^')

  As unfortunately taglist() does not permit to select tags on
  field values, you may have a grep the relevant tags file in
  search of expand('%:t'), keep only the search commands, join
  them in a search pattern with \|, and finally search for the
  newly built pattern.
 
  Another way will consist in parsing the code in search of
  (surrounding) pairs of brackets. A solution should possible
  for simple cases, but I'm afraid it won't be perfect.
 
 I've enough experience with the issues that I could hack up a
 quick parser in C++ which would return the correct position.
 The only question then is how to get vim to use it.  The idea,
 basically, would be to invoke the program with the current
 line number as a parameter, and the buffer on standard in, let
 it do the search, and output the target line number.  But how to
 integrate this into vim?

Writing the C++ parser will be much more complex than integrating its results 
in vim.
There are several ways to proceed:
- if the parser produces a tags compatible file, then calls to taglist('.') + 
filter()map() will return the list of line where the function are. The parser 
will need to be called with something like :!$PARSER %:p.

- if the parser returns its result on stdout, its result can be obtained with a 
call to system(). Supposing it will be a list of numbers, we can have something 
like:
   :let lines = split(system($PARSER.' '.expand('%:p')))  you may want to 
cache this information
   :call sort(lines)
lh#find_if is non standard, but easily implemented with a :for loop
   :let next_idx = lh#list#find_if(lines, 'v:1_ = '.line('.'))
   :exe lines[next_idx]  ~ jump to the next position

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: how to manage complex insertions with key combos

2009-09-29 Thread Luc Hermitte

Harry Putnam rea...@newsguy.com wrote:
  Or set 'runtimepath' to include .vim/xpt/
 
 How can I make vim show me its runtimepath?

:echo rtp
:echo runtimepath
:set rtp?
:set runtimepath?

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: how to manage complex insertions with key combos

2009-09-28 Thread Luc Hermitte

Hello,

Harry Putnam rea...@newsguy.com :
 The difference is that trying to create a complicated format,
 especially a long one, can get really complicated in the iab system.

There exist a lot of template/skeleton expander plugins. Each has its own 
format. Most of them are listed there :
  http://vim.wikia.com/wiki/Category:Automated_Text_Insertion

I'm maintaining the fork of mutemplate.
The expansion in insert-mode is done with c-rtab by default, you can bind 
it to any other keystrokes -- :h PlugMuT_ckword

You can specify where the cursor will jump to with placeholders like '++' (or 
any other string as it can be specified in each template-file) -- the cursor 
will jump to the first placeholder in the template-file.


XPtemplate should also answer yours needs. What its author has done with 
placeholders is really neat.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: How to control commenting with keycombo

2009-09-26 Thread Luc Hermitte


Tim Chase v...@tim.thechases.com wrote:
  Have a look at EnhancedCommentity.
 
 I think Luc mistyped EnhancedCommentify :)

Oups. Indeed :)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: How to control commenting with keycombo

2009-09-26 Thread Luc Hermitte

Harry Putnam rea...@newsguy.com wrote:

 I wondered if anyone can show me how to write something for
 commenting better than what I was able to do:
 [...]

Have a look at EnhancedCommentity.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Function key in vim script

2009-09-16 Thread Luc Hermitte

Hello,

J Hofmann j.hofm...@e-punkt.eu a écrit :

 How can I trigger a function key in a script?
 
 I tried
 normal F5
 and
 execute 'F5'
 but this does not work.

It's both. :)
  :exe normal \F5

You can also consider returning an expression from your function and execute it.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Copy file using vim scripting??

2009-09-16 Thread Luc Hermitte


Pablo Giménez pablog...@gmail.com :

 Is it possible, looking at the help I haven't found any function to
 make file operations, crossplatform, to move/copy/rname files etc ..
 I mean using vim scripting.
 Is it possible?

It seems you missed at least:
- rename(), which moves and renames
- delete()
- filewritable()
- fileredeable()
- getf*()
- resolve()

Regarding the copy, you'll have either to play with readfile() and writefile(), 
or to encapsulate system calls to cp/copy depending on has(*) results.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: split window many times and open many files in each at once

2009-09-15 Thread Luc Hermitte

Hello,

Daniel Fetchinson fetchin...@googlemail.com wrote :
 This in itself is pretty cool, but now I'd like to make something
 even cooler by hooking up a custom function to do this. This is 
 where I'm currently failing. What I'd like to see is when I type
 
 :msplit filename*

If I may, I provide a plugin that already does this (and much more)
The multiple split commands are :Split! and :Vsplit (banged).
 -  http://code.google.com/p/lh-vim/wiki/searchInRuntime

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Where do functions go?

2009-09-15 Thread Luc Hermitte

Matt Wozniski m...@drexel.edu wrote :

 Of course, autoload functions aren't a silver bullet, either.  If you
 have a function that you use every time vim starts (either because
 it's called by a plugin, or your vimrc, or a statusline, etc), then
 it's almost certainly slower to put it in an autoload script, even if
 that's nicer for organization.  

Except when the function is required by two or more plugins.

Copy-pasting the function is not a good idea for obvious (at least, IMO) 
maintenance reasons.

And cluttering all plugins, but one, with :runtime 
plugin/theonethatgotthefunction.vim is not better than relying on autoload 
plugin mechanism which at least caches when a function has already being loaded 
-- the :runtime is required as there no useful guaranty regarding the order in 
which plugins within a same directory are loaded.

 Personally, I tend to put all the functions for my scripts into
 plugins/ and then, once the scripts become too large, or I notice
 that a lot of overhead goes into interpreting code that's rarely 
 used, etc,
 I start pushing things out to autoload functions.  I try to keep my
 vimrc free of functions that aren't directly used by it, though.

I have a lot of plugins installed, and its extremely rare I need to run all of 
them during a same vim session. Hence I'm slowly refactoring my plugins to 
extract their functions into autoload plugins, and call them from the :command, 
mappings, abbreviation defined in the plugins.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Where do functions go?

2009-09-15 Thread Luc Hermitte

Patrick Gen-Paul pgenp...@gmail.com wrote:

 BTW, has anyone ever had vim crash on them? ;-)

Yes, unfortunately. :(

Once a month I have to restart vim, and sometimes it crashes on the way.

After more than 1000 buffers opened, closed, and plenty split windows as well, 
sometimes I experiment what looks like a resource leak on Solaris: eventually 
Exceed starts to behave oddly regarding the x-windows it displays. I often have 
to close a few vim-windows to temporarily fix the odd behaviour until I can 
eventually stop vim and restart it.
(As I did not have the time to investigate on my end, I never sent any bug 
report)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: How to force Vim to not replace text in memory after paste

2009-04-09 Thread Luc Hermitte

Hello,

Jakub Marian kuba...@gmail.com wrote :

 Hello,
 
 I am sure that this is an easy question, but I wasn't lucky in 
 finding the answer. Suppose that I yanked something (using y or 
 yy) and I want to paste it over several places (without yanking 
 it into some register). But when I select some text and press 
 p or P, the selected text is then yanked instead of the text 
 before, so I have to select it and yank it again. Is there any
 way to tell Vim that I want to keep the originally yanked text
 in memory?

I have a plugin that does that, 
http://code.google.com/p/lh-vim/source/browse/misc/trunk/macros/repl-visual-no-reg-overwrite.vim

And Andy Wokula sent me a nice patch I haven't integrated yet:


vmap p SIDreplSIDrestore
vmap P p
vnoremap expr SIDreplsidRepl()
nnoremap expr SIDrestore sidRestore()

func! sidRepl()
let s:reg = [getreg(@), getregtype(@)]
return p
endfunc

func! sidRestore()
call setreg(@, s:reg[0], s:reg[1])
return 
endfunc




HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: iabbrev for templates

2009-03-01 Thread Luc Hermitte

Hello,

Archibald Chase archibald.ch...@gmail.com a écrit :
 In a french magazine an article presents a lot of vim features. For a
 simple use of templates it says that  html template could be use this
 abbrev :
 iabbrev img img src='!cursor!' alt='+Message de remplacement+'
 /CRESC 
 :call search('!cursor!', 'b')CRcf!

When written on two lines, mappings/abbreviations/... 
must use a '\' in front on each new line.
  :h line-continuation

BTW: there already exist frameworks that help define such 
mappings, like mine for instance: 
   http://code.google.com/p/lh-vim/wiki/lhBrackets#The_VimL_library

With InsertSeq(), your mapping will be written as follow:
   inoremap buffer img 
  \ c-r=InsertSeq('img', img src=!cursorhere! alt='!mark!'/)cr

(I suppose it will be defined into {rtp}/ftplugin/html_snippets.vim 
as you probably won't like to see the mapping exists when editing 
C++ files, see :h map-buffer, :h ftplugin)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Visual-mode pasting modifies unnamed buffer. Correct?

2009-02-24 Thread Luc Hermitte

Hello,

Ben Fritz fritzophre...@gmail.com wrote :
  Also, is there any way to disable this behavior? I'm happier
  knowing that only d, c, s, 'x, and y put things into the
  unnamed buffer.
 
 :vnoremap p _d0P or similar ought to do it.

In order to avoid overwriting the @ register, but still being able to
paste the content of any register, I came up with this [1]


 I haven't found how to hide this function (yet)
function! RestoreRegister()
  let @ = s:restore_reg
  return ''
endfunction

function! s:Repl()
let s:restore_reg = @
return p...@=restoreregister()\cr
endfunction

 This supports rp that permits to replace the visual selection with
 the contents of @r
vnoremap silent expr p sidRepl()



[1] This dozen lines is maintained there:
http://code.google.com/p/lh-vim/source/browse/misc/trunk/macros/repl-visual-no-reg-overwrite.vim

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: my NewBufferAsMenu() don't match line

2009-02-13 Thread Luc Hermitte


Hello Marc,

Marc Chantreux kha...@phear.org wrote :

 On Thu, Feb 12, 2009 at 05:41:58PM +0100, Luc Hermitte wrote:
  which I have used in several places:
  - lh-tags
   
 http://code.google.com/p/lh-vim/source/browse/tags/trunk/autoload/lh/tags.vim
 
 Well ... my main problem was to handle the callback. Can you point
 the function that actually does it ? 

OK. Here is a little tour on the library. It was initially designed
to display (in a scratch buffer) a list of things, select (/tag) one
or several items, and validate the choice.

The items can be of any kind (function signatures, email addresses,
suggested spellings, ...), as well as the validating action.  The
help/header can be customized as well as colours, other mappings, ...

However the list displaying + selection aspect is almost hardcoded. 


How it Works:

Scripts have to call the function 
  lh#buffer#dialog#new(bname, title, where, support_tagging, action, choices)
with:
- {bname} being the name the scratch buffer will receive.
- {title} the title that appear at the first line of the scratch
  buffer.
  I use it to display the name of the client script, its version,
  and its purpose/what to do
- {where} are :split options (like bot below) used to open the
  scratch buffer
- {support_tagging} is a boolean (0/1) option that permit to select
  multiple items
- {action} is the name of the callback function (I may support more
  advanced calling mechanisms latter)
- {choices} is the |List| of exact string to display

The #new function builds and returns a dictionary, it also opens and
fills the scratch buffer, and put us within its context.
If we want to add other mappings, and set a syntax highlighting for
the new buffer, it is done at this point (see the s:PostInit()
function in my client scripts).
At this point, I also add all the high level information to the
dictionary (for instance, the list of function signatures is nice, but
it does not provides enough information (the corresponding file, the
command to jump to the definition/declaration, the scope, ...)

The dictionary is filled with different useful information:
- buffer ids
- where we was at the time of its creation
- name of the callback function


The callback function:
- It can't be a script local function.
- When called, we are still within the scratch buffer context
- It must accept a |List| of numbers as parameter: the index (+1) of
  the items selected
- The number 0, when in the list, means aborted. In that case, the
  callback function is expected to call lh#buffer#dialog#Quit() that
  will terminate the scratch buffer (with :quit), and jump back to
  where we were when #new was called, and display a little Abort
  message.
- We can terminate the dialog with just :quit if we don't need to jump
  back anywhere. For instance, lh-tags callback function first
  terminates the dialog, then jumps to the file where the selected tag
  comes from.

- It's completely asynchronous: the callback function does not return
  anything to anyone, but instead applies transformations in other
  places.
  This aspect is very important. I don't see how this kind of feature
  can work if not asynchronously in vim.


Limitations:
This script is a little bit experimental (even if it the result of
almost 10 years of evolution), and it is a little bit cumbersome.
- it is defined to support only one callback -- see the hacks in
  lh-tags to workaround this limitation.
- it is defined to display list of items, and to select one or several
  items in the end.
- and of course, it requires lh-vim-lib, but nothing else.

 But sure: i prefer to contribute to an existing code instead of code
 mine.

Feel free to change it in any way you wish. As long as supporting list
of items is still simplified (as it is used in 4 others scripts), it
is fine with me. In the end, it'll likelly end up in Marc Weber TOVL
project.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: my NewBufferAsMenu() don't match line

2009-02-12 Thread Luc Hermitte

Hello,

- Marc Chantreux kha...@phear.org a écrit :

 My pb is that Foo doesn't care about the line under the cursor and
 always reply 0. 
 [...]
   nnoremap buffer space :echo g:CallBack()cr
 [...]
 function! Foo()
   echo 'find '.line('').', add'.getline(line(''))
   let g:boom=getline(line(''))
   bd!
 endfunc

Your Foo function doesn't return anything ...



BTW, I have a similar framework: 
  http://code.google.com/p/lh-vim/wiki/lhVimLib#Buffers_related_functions
which I have used in several places:
- lh-tags
  http://code.google.com/p/lh-vim/source/browse/tags/trunk/autoload/lh/tags.vim
- lh-cpp/UnmatchedFunctions
  
http://code.google.com/p/lh-vim/source/browse/cpp/trunk/autoload/lh/cpp/UnmatchedFunctions.vim
- lh-cpp/Override
  
http://code.google.com/p/lh-vim/source/browse/cpp/trunk/autoload/lh/cpp/override.vim
- and lh-cpp/constructor (not yet released)
  

I have a few thing to re-think [*], however most of the features needed are 
already implemented.

[*] it was initially designed with only one conclusive action in mind (or abort)

HTH,
-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Dealing with address books

2009-02-11 Thread Luc Hermitte

Hello,

Nicolas Sebrecht nicolas.s-...@laposte.net wrote :

 On Tue, Feb 10, 2009 at 09:45:10PM +0100, Luc Hermitte wrote:
 
  I have an old mail ftplugin that takes care of this, check:
 ^^^
 Should I be scared ?

Well ... that a tough question. ^^'


 http://vim.sourceforge.net/scripts/script.php?script_id=46
  (the last version being bundled in the following archive)
 http://hermitte.free.fr/vim/ressources/lh-mail.tar.gz
 
 Downloaded and tried. It looks like to be exactly what I need.
 
  On the To:, Cc:, ... lines, type a regex, then tab, and finally
  select the contact(_S_) you want on insert. And that's all.
 
 I couldn't have it working for now. Copying both ftplugin/* and
 plugin/ into ~/.vim isn't enough. I've read the comments at 
 the beginning of ftplugin/mail/Mail_mutt_alias_set.vim. 
 The installation seems ok but the
 tab completion still fails (by adding a tabulation \t).

What error message do you observe ?
IIRC, the ftplugin expects the aliases file to be formatted with \t between 
each field.

 I've tried to copy a-old.vim to a.vim in case but it didn't help.
 
 What am I missing ?
 
 By the way, is it possible to set more than one single aliases file ?

It shouldn't be very complex, however you'll have to hack into the ftplugin to 
make it work that way.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Dealing with address books

2009-02-11 Thread Luc Hermitte

Nicolas Sebrecht nicolas.s-...@laposte.net wrote :

 On Wed, Feb 11, 2009 at 02:24:25PM +0100, Luc Hermitte wrote:
 
  What :imap tab, or :echo g:loaded_Mail_mutt_alias tell you 
  (when you are editing an email) ?
 
 :echo g:loaded_Mail_mutt_alias tells 1'.
 
 :imap tab chenge the command line into :imap ^Wf.
 :imaptab does nothing.
 :imaptabtab change the line into :imapclear

I meant tab as in 5 keystrokes, not the tab key.

  Are ftplugins enabled ?
 
 Hmm. Aren't they automatically sourced ?

It depends on our .vimrc, not every one has enabled ftplugins in the .vimrc. 
Hence my question.
However, as g:loaded_Mail_mutt_alias values 1, it should have been loaded. Do 
you have any message when opening vim to edit emails ?

You can send me directly (i.e. not on the mailing list) an excerpt of your 
aliases_file to see how vim 7.2 behaves.

  A SVN one, but my mail-ftplugins are not there (yet).
 
 Address please ?

Check the first link in my signature ^^

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Is it possible for the vim tag system to distinguish between functions with the same name but different signatures?

2009-02-11 Thread Luc Hermitte

Dominique Pelle dominique.pe...@gmail.com wrote :
 As far as I know, there is unfortunately no solution
 yet for this.  It's been discussed in this mailing list
 a  couple of times. It's the feature that I would like
 most when developing in c++ with Vim.

In my CC++ suite and in my lh-tags experiment (*), I already have the bricks 
to build upon in order to implement such a beast (I just lack time).

In lh-cpp/AnalysisLib_Function and gotoimpl autoload/API plugins, there are 
functions able to parse the signatures of C++ functions, and build a robust 
(regarding comments, multiple lines, and optional parameter names) (but slow to 
match) regex ready to use.

lh-tag is already able to propose to select which exact tag we are interested 
in. However, at this time I use the default search command as defined by ctags. 
With a customizable hook, it should be possible to use the overloads-aware 
regex from gotoimpl.

I'll try to upload the latest version of the scripts this week-end, in case 
someone is tempted to play with them.


(*) NB: I've never used the other tags related plugins, my experiment is likely 
to be redundant with them in many places.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Dealing with address books

2009-02-10 Thread Luc Hermitte

Nicolas Sebrecht nicolas.s-...@laposte.net wrote :

Hello,

 I'm using vim here with mutt. I would like to know how you improve
 your mutt mail_aliases file in vim to write emails.
 
 What I'm looking for is a kind of smart completion for fields like
 To: or Cc:.

I have an old mail ftplugin that takes care of this, check:
   http://vim.sourceforge.net/scripts/script.php?script_id=46
(the last version being bundled in the following archive)
   http://hermitte.free.fr/vim/ressources/lh-mail.tar.gz

On the To:, Cc:, ... lines, type a regex, then tab, and finally select the 
contact(_S_) you want on insert. And that's all.


HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: text objects

2009-02-07 Thread Luc Hermitte

Hello,

Oleksandr Manzyuk manz...@googlemail.com :

 I have a general question: Is there a way to create custom text
 objects in Vim (or to redefine the existing text objects)?

Yes, you will have to define an o-map that plays with visual
selection. I can't tell whether this is a normal behaviour or 
just a temporary hack that will stop working eventually.

On vim.wikia, there is a tip that shows how to define such a 
mapping. 
  http://vim.wikia.com/wiki/Indent_text_object

I've applied it to define a motion that select parameters 
(in function calls or definitions).
  http://code.google.com/p/lh-vim/source/browse/cpp/trunk/plugin/omap-param.vim

NB: it requires my vim-library available on the same site.

[...]
 so I am thinking about writing my own plugin, but I am 
 confused: what are text objects from the point of view 
 of Vim script? Note that I want text objects to be used 
 both in Visual and Operator-pending mode.

You will also have to define a separate visual mode mapping.

HTH,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Automatic documentation

2009-02-05 Thread Luc Hermitte

Hello,

Alberto Parnaso pafba...@yahoo.es wrote :

 Hi, I am looking for an automatic tool/pluging to use in VIM for
 documentation. Something like javadoc. Do anyone know any?
 Thanks! and regards..

What are you looking for exactly ?
- vim already has syntax highlighting for doxygen/javadoc comments

- a few plugins helps to define comments related to the function to 
comment (I'm maintaining one for C++/doxygen that extracts all it 
can from function signature (whether something is returned, the
direction of the parameters (in/out), exception specifications) 

- something that displays the javadoc/doxygen documentation associated
to the current symbol (class/function/...) ? However, I'm not aware
of any plugin that implements such a feature.

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: case insensitive iabbrev

2009-02-05 Thread Luc Hermitte

Hello,

Szymon Guz mabew...@gmail.com wrote :

 is there any way to have some kind of case insensitive iabbrev to
 have it like this:
 
 iabbrev integer INTEGER

May be you can try to adapt imaps.vim (distributed with LaTeX-suite)
and make it case insensitive ?

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Rules for replying to posts on this list (Was: Easiest way to insert a blank line?)

2009-01-07 Thread Luc Hermitte

Hello,

Tom Link micat...@gmail.com wrote:
 IIRC there is a rfc about quoting (maybe it's part of the netiquette)
 and inter-posting is widely considered good practice. IMHO the
 function of a quote is to make clear what you're referring to not to
 repeat what has been said.

Sven Guckes used to maintain a how-to about posting.

http://web.archive.org/web/20020219152132/http://www.math.fu-berlin.de/~guckes/mail/edit.html


PS: Happy new year.
-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Error uploading new plugin AutoTmpl

2008-11-28 Thread Luc Hermitte

Hello,

Bram Moolenaar [EMAIL PROTECTED] a écrit :
  Hi all. I've had problems uploading a new plugin (AutoTmpl) and I've
  ended up
  with two IDs on the scripts web, 2460 and 2461.

 I can see both script pages and they are owned by you.  

Indeed, it has been uploaded.


BTW, the latest version of mu-template is maintained there: 
http://code.google.com/p/lh-vim/wiki/muTemplate

I've completely rewritten the expander engine since the version you have based 
your script on. The s:Execute function I've sent to Gergely was a quick that 
did not fulfil correctly what it should.

Regards,

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Intesting blog posts of 10 year [..] - What do we (community) want to do to improve things ?

2008-11-20 Thread Luc Hermitte

Hello,

 d) The *one* way to search 
   - for scripts or libraries
   - update them
   - distribute them
   - customize them
   - document them
   - evaluate them (not only +1 / 0 / -1, but you should be able to
 give feedback easily!) [1]
   - reusing code this way
 
   that thing that vim is lacking but PHP, ruby etc all have (?)
 
   Does this *one* way exist? I mean vim runs on linux, windows (maybe
   cygwin).. so at least there must be some boilerplate code to handle
   file paths correctly in all cases (can this be done at all?)..

I have some old functions for that issue.

   I'm using cygwin for that reason because it just works the way I'm
   used to unless you want to parse compiler messages with C:\ in it..
 
 If someone is interested in building up a vim-framework providing
 some of the functions (background compilation, outline features, easy
 script configuration setup, ..etc) let me know. 

I remember you had your framework online. Did you remove it?

Otherwise, yes. I'm quite interested by the library/framework 
side of things ; even if there are a lot of redundant code 
between our two frameworks. :)

Actually, I'm already maintaining a few more or less dependant 
frameworks. See http://code.google.com/p/lh-vim/wiki/lhVimLib 
for the more general one.
[I'm currently adding boost.bind-like functions that I'm planning 
to use in order to simplify my refactoring plugin.]


 I've already written an
 alternative vim script distribution system figuring out dependencies
 automatically so that autoloading can be exploited fully.

That sounds interesting. Having to say to use this plugin, you have 
to install the following 4 vimballs, as I'm currently doing, does not 
seem to be the right way. I'll have a look at your solution.

[...]

 Looking at my comments below you see one sentence a way to often
 never got any feedback..

Sometimes, I have some feedback. But that's quite rare. Unless our scripts
are exceptionally visible, we won't get much. Library oriented script seem 
to me to be the worse kind: most of us prefer to reinvent the wheel instead 
of relying on external library-plugins.

 So I'd like to improve that. Is there any way to make www.vim.org
 accept comments from other users ?

I did move my scripts to googlecode to track their evolutions, bugs and RfC.
May be, I'll move them back to vim.org if it eventually offer what has been 
discussed in the other thread about vim.org and scripts hosting.


-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: How to map one shortcut for visual, normal and insert mode in one line?

2008-11-12 Thread Luc Hermitte

Hello,

sc [EMAIL PROTECTED] wrote:

 but Pento:  you've written 18 lines of function to save about 4 lines
 in .vimrc -- seems like a net loss to me

I did much worse [1]. However, my aim was to be able to generate
mappings and menus entries for several modes at once.

For one very simple mapping like this one, we don't see the gain, 
however, when we start to have something like 15-20 mappings for 2-3 
filetypes, the gain is quite visible.
Hence, this is a need I understand quite well. 


[1] http://code.google.com/p/lh-vim/wiki/lhVimLib#Menus_related_functions

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Full path of current file?

2008-11-05 Thread Luc Hermitte

Hello,

703designs [EMAIL PROTECTED] wrote:

 OK, thanks. I'm writing a plugin [...]
 and I'm not sure how to find their path (I intend to
 distribute the plugin). How could I assign the absolute path of one
 of
 these scripts to a variable? I posed a separate but similar question
 earlier about finding the path to $HOME/.vim or $HOME/vimfiles. I
 don't need to load the script into Vim, rather, I have to pass its
 path into a shell command (using exec).

You're looking for this:
* To find the full pathname of the script from itself
   let s:script_name = expand('sfile:p')

* from elsewhere
   let path_to_script = globpath(rtp, 'plugin/the_script.vim')
(which may require some other processing if the file is found several times)

-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Code repetition in Vim mappings

2008-10-18 Thread Luc Hermitte

Hello,

703designs [EMAIL PROTECTED] :

 Following this tip:
 http://vim.wikia.com/wiki/Automatically_append_closing_characters#Improved_Bracket-Matching
 
 I've pasted the code three times, replacing ( with [ and {, ) with ]
 and } respectively for the latter two. 
 [...]
 Any ideas as to how I could extract the second
 mapping into a function, taking one argument for the matched
 character? 

The first version of my bracketing system was quite impossible to evolve and 
maintain. In the last version (*), I've provided a command that helps define 
normal-, visual- and insert-mode bracket-mappings.

(*) The v1.0.0 is only available through subversion at that moment: 
http://code.google.com/p/lh-vim/wiki/lhBrackets

Otherwise, you have several options:
1- play with :exe to map with options
   :exe inoremap silent .open. .open.close.left

2- Have a function that execute the mapping itself ; the function will play 
with exe+normal

3- Have an expr-mapping that expand the result of the called function.


HTH,
-- 
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---