Jump to content

AutoIt Vim syntax file


nitro322
 Share

Recommended Posts

It seems to have trouble when being called the first time. For example, if I open an existing AutoIt file, enter a new line and then enter 'str<C-x><X-o>', I get an "Unknown error" erroe message in the status bar. A couple seconds later, the OmniFunc drop-down list appears showing me EVERY function available, automatically selects Abs (since it's the first), and appends Abs to what I had originally typed, so that I'm left with 'strAbs' on the line. If I clear the line and repeat the process, it'll work like a charm, only showing functions that begin with 'str'.

I'm not at my pc now, but I'll look what can cause this problem. I'm afraid it's something about setting the omnifunc. That unknown error is what prevents vim from getting the first part of the word and so the completion list is the whole list.

If I initiate omni completion on a function that's already specific enough that there's only one match (eg, 'stringin<C-x><C-o>'), the function name gets completed, but the function syntax is not displayed. The syntax only seems to be displayed when the function is selected from multiple options.

omni-complete is complex and it has many options to satisfy all tastes. You have to add menuone to 'cot' option.

:help cot for more info

If we're talking about function completion here, maybe it'd be a good idea to automatically add the () as well? Eg, if I select StringFormat from the list, would it be possible to type out StringFormat(), with my cursor in between the parens (shown by the underscore)?

the cursor will be placed at the end of the completion. It's a vim matter. Of course, the completions can end with a "(", maybe a map or abbr should do the trick for the closing paren and cursor moving, but if you move through the list with c-p/c-p , the effects will be different from up/down moving.

I don't particularly like how the preview window works. Popping up to show me the function syntax is great, but I'd like it to also go away. As it is, I have to hit <C-w><C-o> to make it go away after each and ever OmniFunc call. Would it be possible to automatically hide it after the function entry has been completed? Eg, after the cursor moves outside of the parens, or perhaps when moving to a new line?

If you want to close the preview window you can imap <cr> to call a function that searches for the preview window and closes it, then return a <cr>

Ok, this last one will seem odd. I was poking around through your completion file to see how it works, and noticed that you have all functions detailed on a single line. This is probably the single longest line I've ever seen. So, first of all, props for having the patience to work with that. It would've driven me crazy. ;-). Second, according to some limited testing, it seems that the milista line can be broken up on multiple lines using \.

This would obviously increase the length of the file significantly, but I find that this single-line approach greatly enhances readability and maintainability. Have you considered changing to this format?

ok. I'll change that. That huge list was created opening the autocomplete file for scite( http://www.autoitscript.com/autoit3/scite/download/au3.api ) with vim , and

:%s:\([^)]*\)).*:\1)  
:2,$s:^.*$:,'&' 
:%j!

I actually haven't noticed how big is because I deal with it "globally"

Happy vimming

Link to comment
Share on other sites

Trying to keep the "standard" funcionality of K in normal mode (opens man or vim help of the word under the cursor), I've done a quick hack to extend it on autoit files.

It has few dependencies:

-Scratch plugin for vim.

-Lynx for win32. A text-mode browser.

When pressing shift+k on a word like MsgBox , it will open a new buffer with the help on MsgBox. This can be done thanks to the well organized online help of autoit.

nmap <buffer> K :call ayuda(expand("<cword>"))<cr>
fu ayuda(paraula)
    "echo a:paraula
    execute ":Scratch"
    normal ggdG
    execute":r !c:\\apps\\lynxy\\lynx.exe -dump http://www.autoitscript.com/autoit3/docs/functions/" .a:paraula. ".htm"
    normal gg
endfu

Vim is quite advancedand and may be difficult to learn , but as you can see, it is one of the more "usable"/intelligent editors over there if you tweak it well. XD

Happy vimming

Edited by kidd
Link to comment
Share on other sites

I like VIM, and will at some point learn it better as I have Windows and Linux environments. I am glad to see it now has AutoIt support. Keep up the good work!

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • 2 months later...

I just updated the syntax file again to support AutoIT v3.2.0.1. There isn't much new aside from a few keywords here and there and the entire IE UDF section, but you may want to update just to get current with the stable version.

I've also submitted this for inclusion in the official Vim distribution, so hopefully support will be available by default in future versions of Vim.

Link to comment
Share on other sites

  • 2 months later...

This is an existing vim indent file (for vim filetype) adapted to indent autoit files.

As I don't know much about vim indent files, I just copied vim.vim to autoit.vim, and put it in my indent directory. Then, quick substitution of words did the trick, but I'm sure there are lots of bugs/annoyances. If someone can take a look at it, and improve, we could upload it to vim.org .

As it's an alpha version, don't expect it to work very well.

Multiline expressions are not changed to work in autoit files, but the section is left to have a sample of how should it look like...

Byez

Link to comment
Share on other sites

  • 2 months later...

FYI, I just uploaded version 1.5 of the script, which has been updated for AutoIt 3.2.2.0. I've also exchanges a few e-mails with the Vim author, and this version of the syntax file should be included with the next official release of Vim. w00t. I still plan on updating the file as needed, though, so check http://www.vim.org/scripts/script.php?script_id=1239 for updates.

Link to comment
Share on other sites

  • 4 months later...

FYI, I just uploaded version 1.6 of the script, which has been updated for AutoIt 3.2.4.9. As noted previously, support for AutoIt is now included in the official Vim release, beginning with 7.1. Keep in mind, though, that only version 1.5 of the script is included; to add support for the latest AutoIt syntax, download the newest version from http://www.vim.org/scripts/script.php?script_id=1239 (or from the first post of this thread) and replace the copy of autoit.vim that was installed with Vim.

Link to comment
Share on other sites

  • 8 months later...
  • 7 months later...

hah...finally got the omniautocompletion to work with supertab.vim(required).. and i must say...its quite nice how fast you can work with this vim-thingy (yezzzz i did the tut :-) )

Posted Image

-edit- nice to mention: im using the portable version of Gvim, so always with me on the go. Its still 7.1 instead of 7.2 but that not really important to me

Edited by Creator
Link to comment
Share on other sites

  • 6 months later...
  • 4 weeks later...

FYI, I just attached v1.9 to the parent post, which is updated for version 3.3.0.0.

Hi nitro,

I made an autoit "ftplugin" for Vim, which I think complements quite well you fantastic autoit syntax file.

What it does (for those that do not know much about vim or ftplugins) is that whenever you load an autoit file, it configures some hotkeys to be able to check AutoIt3 syntax, run scripts, compile them, etc. I've set the hotkeys so that they are the same (or as close as possible) to the ones used by Scite4AutoIt:

- F2: Show the AutoIt help for the current word (the word under cursor). I could not use F1 since it is already taken by Vim's help file

- F5: Run script

- Ctrl+F5: Check script syntax using Tylo's AutoIt Checker

- :make -> Same as Ctrl+F5, but tries to pipe the output of the checker to Vim

- F7: Compile script

As a bonus, you can also easily navigate through the defined functions in your script by using the "]]" and "[[" key combinations.

It is based on Vim's visual basic ftplugin, and I think that it works quite well, although it has a few shortcomings:

- I have not been able to pipe the output of Tylo's autoit checker into the Vim error parser (which can be started by doing Ctrl+F5 or by using the :make command)

- I have not been able to get rid of the "windows command prompt" window that appears when you run a script using F5.

- When you compile a script with F7, if there are errors the error message is not shown.

Other than that I am quite happy with it. Perhaps you can give it a try and if you like it maybe it could be added to Vim's ftplugin list?

Also, any help on improving this would be welcome. Scite is not bad, but I'd rather be able to use Vim for all my autoit coding.

Cheers,

Angel

Link to comment
Share on other sites

Hi,

I am an avid vim user but have some questions about using it for AutoIt. Obviously it would be nice to retain, in addition to syntax highlighting:

1. auto-complete

2. F1 help lookup.

3. Shortcuts to compile/run/stopexecuting

From what I've read in this thread so far, it looks like 1. is possible using omniautocomplete, but I couldn't find info on how to set that up, or specific info on getting it setup to work with autoit. Is there an omnicomplete config file (similar to a syntax highlighting file) specifically for autoit? For 2. and 3., I wasn't sure what the best solutions were....

Thanks,

Jonah

EDIT: Angel just posted before me, so I guess his plugin answers points 2. and 3.

Edited by gamingmouse
Link to comment
Share on other sites

  • 3 months later...

Sorry for the delayed response, but I just saw those last two replies. I haven't been doing much Windows development lately, so I haven't really been following these boards. As for your posts:

Angel - sounds pretty cool. I'll definitely need to check it out. I have some similar functionality defined in my .vimrc file (eg., run the file with F5, compile with F6, etc.), but your plugin sounds much more complete. I'll give it a shot next time I'm working with AutoIt and let you know what I think (if you're still interested at that point :-) ).

gamingmouse - I definitely like your ideas, and I've briefly looked into omnicompletion before, but it didn't really click with me. To be honest, I'm not very familiar with how syntax files are "supposed" to be written. I took over maintenance of an existing syntax script after the original author disappeared, and despite adding quite a bit to it over the years I'm still largely using his original structure. When I do my next update I'll look into this again, see if I have any better luck the second time around.

Link to comment
Share on other sites

  • 1 year later...

Wonderful Work!

Plz UPDATE it for 3.3.6.1

I wouldn't hold your breath on that one.:mellow:

The file is a text file that can be updated by anyone, it should be easy enough for a VIM user to update it for any new UDFs that were added in the past 2 years since this was last updated.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...