xigoi / vim-arturo

A Vim plugin for the Arturo language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trouble installing the plugin on macOS

drkameleon opened this issue · comments

DISCLAIMER: I'm a total newbie with Vim and have literally had to look up every single thing, but still haven't managed to test the plugin.

So...

I'm using macOS BigSur (11.0.1) with MacVim installed.

I've created a ~/.vim/after folder and put all the folder from this repo in there. This is what the folder looks like:

after/ftdetect:
total 8
drwxrwxr-x@ 3 drkameleon  staff   96 Feb  1 22:20 .
drwxr-xr-x  5 drkameleon  staff  160 Feb  2 09:32 ..
-rw-rw-r--@ 1 drkameleon  staff   52 Feb  1 22:20 arturo.vim

after/ftplugin:
total 8
drwxrwxr-x@ 3 drkameleon  staff   96 Feb  1 22:20 .
drwxr-xr-x  5 drkameleon  staff  160 Feb  2 09:32 ..
-rw-rw-r--@ 1 drkameleon  staff   56 Feb  1 22:20 arturo.vim

after/syntax:
total 8
drwxrwxr-x@ 3 drkameleon  staff    96 Feb  1 22:20 .
drwxr-xr-x  5 drkameleon  staff   160 Feb  2 09:32 ..
-rw-rw-r--@ 1 drkameleon  staff  4083 Feb  1 22:20 arturo.vim

Then I re-open MacVim.

When I check the sources scripts, I'm getting:

Screenshot 2021-02-02 at 09 44 40

So, I guess the main detection script is being taken into account.

However, when I check a dropdown with the detected syntaxes/languages, Arturo is not there:

Screenshot 2021-02-02 at 09 45 50

Also, opening an .art file, doesn't seem to pick up Arturo-specific symbols - so I guess it's just recognizing it and highlighting it as something else.

I don't know...

Any ideas?

P.S. If you don't mind, I'll also include a link to the plugin in the main Arturo README ;-)

Try putting the ftdetect directory directly inside .vim. I'm not sure if it works in after, and personally I use a plugin manager.

And of course you can add a link to this ;)

Try putting the ftdetect directory directly inside .vim. I'm not sure if it works in after, and personally I use a plugin manager.

I tried that too - basically I'm so Vim-illiterate that I've been moving files around until it magically works, to no avail ...lol

That's a bummer. I added instructions in the README for installation with vim-plug, so you can try that.

It seems that Vim has built-in support for another filetype that uses the .art extension, so that may complicate things.

What is the output of :set filetype? when you open an Arturo file?

That's a bummer. I added instructions in the README for installation with vim-plug, so you can try that.

It seems that Vim has built-in support for another filetype that uses the .art extension, so that may complicate things.

What is the output of :set filetype? when you open an Arturo file?

filetype=art

So it seems the detection was overriden by Vim's detection of the ART filetype. You can try entering :set filetype=arturo to correct it manually, but I'll try to investigate.

:set filetype=arturo

Magic! Yep, that did work! Great, great! :)

Screenshot 2021-02-02 at 10 22 39

Btw... Linked added. Arturo has officially Vim support too - thanks to you! 👍

https://github.com/arturo-lang/arturo#editors--ides

I noticed a mistake in your screenshot (only the first character of a literal was highlighted) and fixed it. Now just to make it work without manually setting the filetype…

I noticed a mistake in your screenshot (only the first character of a literal was highlighted) and fixed it. Now just to make it work without manually setting the filetype…

You mean that 'a, right? I noticed that too. But you fixed it before I even though about mentioning it. Good job! :)

Btw, speaking about syntax highlighting, since I've already implemented the plugin for VSCode... I was a initially a bit unsure how to handle the builtin words/functions. This is a matter of discussions, I don't know what you think... but this is what my problem was:

On one hand, every single word in Arturo is just a word, that can be re-defined or take different meanings/nuances, depending on the context. So, as absurd as this seems, this is perfectly valid:

BTW, you can write “Vim/Neovim” in the supported editors list, this plugin should work with both (I made it with Neovim).

Perfect. I'm fixing it right now!

I'm curious, does it work if you change setfiletype arturo to set filetype=arturo in ftdetect/arturo.vim?

I'm curious, does it work if you change setfiletype arturo to set filetype=arturo in ftdetect/arturo.vim?

Very interesting.

Here's what I did:

  • Changed the file @ ~/.vim/ftdetect/arturo.vim to:
autocmd BufNewFile,BufRead *.art set filetype=arturo
  • Closed MacVim
  • Re-opened it
  • Drag'n'dropped an Arturo (.art) file

It worked beautifully! :)

Great! I changed it in the repository, so now it should always work for new installations.

Awesome job!! 👍

I improved the syntax highlighting, which now includes assignment, multiline strings and string interpolation. Currently the string interpolation is just a single color. I could easily make it actually highlight the contained expression, but it will look weird if non-interpolated strings happen to contain pipes. Do you think it would be worth it? Also, currently every word that starts with : is highlighted as a type. Should I make it work only with actual types? Is Arturo going to get user-defined types?

Great job!

And some very good points.

Re: string interpolation

You have a very valid point. When I created the plugin for Sublime, I decided to also highlight the interpolated expression (as Arturo code). When I created the plugin for VSCode, I decided not to. And to be honest, it looks smoother.

In any case, the pipe (|) as an interpolation delimiter might be a controversial choice. In limited examples - where you just want to batch-replace several symbols or expressions in a string, it works fine. But for bigger chunks of code (especially if the "template" in question is code itself - e.g. in a different language -, might cause different types of adverse effects). In the latest update I've been experimenting with a slightly different variant render.template where the delimiter becomes <| ... |> (pretty much in the same fashion as all interpreted languages do it, <? ... , <% ... and so on), which makes it less ambiguous and less error-prone. I don't know... Open to ideas!

Re: : and types

Another spot-on observation :). As a matter of fact, I've gone through the exact same dilemma. But, given that Arturo - although not really implemented - already features the idea of user-defined types, I believe that recognizing everything in the form of :xxxx as a :type would be more suitable.

Again: awesome job! ;-)

I think <| and |> is a good choice. Some languages use them for the "pipe" operator, which might cause trouble when code in them would be contained in an Arturo string, but I don't think that would happen too often.

Also, I found it weird that Arturo doesn't have literals for negative numbers. Do you have any ideas about that?

Also, I found it weird that Arturo doesn't have literals for negative numbers. Do you have any ideas about that?

Funny thing is I find it rather weird too lol.

Seriously now, the initial idea is:

  • words are words, that is: a sequence of letters. (and preferrably any kind of letter, even a unicode Hanzi character - not that it's implemented yet)
  • numbers are a sequence of digits
  • symbols are one of the following: (excerpt straight from src/vm/value.nim)
SymbolKind* = enum
        thickarrowleft  # <=
        thickarrowright # =>
        arrowleft       # <-
        arrowright      # ->
        doublearrowleft # <<
        doublearrowright# >>
    
        equalless       # =<
        greaterequal    # >=
        lessgreater     # <>
    
        tilde           # ~
        exclamation     # !
        at              # @
        sharp           # #
        dollar          # $
        percent         # %
        caret           # ^
        ampersand       # &
        asterisk        # *
        minus           # -
        doubleminus     # --
        underscore      # _
        equal           # =
        plus            # +
        doubleplus      # ++
    
        lessthan        # <
        greaterthan     # >
       
        slash           # /
        doubleslash     # //
        backslash       #
        doublebackslash #
        pipe            # |     
    
        ellipsis        # ..
        dotslash        # ./
        colon           # :
    
        slashedzero     # ø

Per se, all of them, when parsed, are just that: a symbol.

Now, they may also be assigned some meaning - for example, as "aliases" of some word. (Something which happens in the "system" library and will very soon be an option for any symbol).

For example, + is an INfix alias for the word add. Whether you write it "properly", as a function call (with the function name first followed by the arguments), or with its alias (+) as an infix "operator", the function remains the same, only it doesn't parse/consume its arguments in the same fashion.

Now, let's take the symbol -. This is aliased to the word sub (subtract). So basically the 2 following "phrases" are equivalent:

  • sub x y
  • x - y

If, supposedly, we wrote -1, this would imply something like sub <something that i have no idea what it is> 1.

Could I disambiguate? Well, not so easy.

Arturo's functions may take any type of arguments, but in any case they must have fixed arity. So, if function x (whether a system one, or a user-defined one) is declared with 2 parameters, the evaluator will always look for these two parameters.

In the case of -, where it could be either a subtraction, or the sign of a negative number, things could start getting very confusing. (Because after all -1 or - 1 is parsed as :symbol[minus] :integer[1]) And since one of Arturo's basic principles is to be consistent, I decided not to introduce any ambiguity for something - that at least the way I see it - is not the most common thing in the world.

What I have though is introducing/aliasing a different symbol to neg. But still not sure.

(I've written a lot I guess, but can't help it... :))

Do we have any use for _ yet? If not, it could be used for negation. J does it like that, for a similar reason. Jelly is the other way around, using - for negative numbers and _ for subtraction.

Do we have any use for _ yet? If not, it could be used for negation. J does it like that, for a similar reason. Jelly is the other way around, using - for negative numbers and _ for subtraction.

I had thought of using either ~ or _.

~ has pretty much settled for rendering interpolated strings.

Now, _... was something I was experimenting with as a loop/map short alias (for use with =>), think of it as Nim's it. But not sure, since => implementation is one of the trickiest bits, hence it remains experimental.

So, yes... re-thinking about it, _ could be a nice idea...

Talking about interpolated strings, it might also be possible to highlight the contained axpression only if the string is directly preceded by render or ~. However, that would be quite inconsistent.

I don't really like using _ for it, since it has the pretty much opposite meaning in many languages, including Nim.

Talking about interpolated strings, it might also be possible to highlight the contained axpression only if the string is directly preceded by render or ~. However, that would be quite inconsistent.

I have thought of that too... Not sure.

Perhaps, leaving it as-is, without highlighting the inner expression would be better for now.

I don't really like using _ for it, since it has the pretty much opposite meaning in many languages, including Nim.

You have a point.

What would you think about the & as a candidate? (its last experimental use is as an alias for push/dup, meaning as a way of non-returning functions to pseudo-return, that is duplicate stack top - but not very confident about this either...)

I think & for it is good. I don't really understand how push works since Arturo isn't primarily stack-based, so I'm not sure about that.

I think & for it is good. I don't really understand how push works since Arturo isn't primarily stack-based, so I'm not sure about that.

Quite a few things in progress, so I'll talk about that (it's by no means "tried and tested" - as a matter of fact, right now I'm in the middle of an extreme code cleanup, changing and simplifying some of the implementation details)

A short example:

a: 2 ; 2 is on the stack, we pop it and assign it to a (nothing left on the stack)
b: a ; a's value goes on the stack, we pop it and assign it to b

what if we wanted to return a value from something (a label for instance) that doesn't normally return anything?

We could do for example:

a: b: 3

But this, could not possibly work, since each label "consumes" its parameter.

So... we could "hide" a top-dup somewhere in there....

a: b: push 3

(so initially, there are 2 three's on the stack. b gets the first, a the next one.)

And with an alias (in this case &):

a: b:& 3

(I don't particularly like & for that - I just wanted to pick something only to test the feature... Could be <-, could be <=, could be anything... The point is to turn a non-returning function into a returning one)

Btw, since the project is getting a bit more organized and serious :) , I've decided to also setup a Discussions sections. Still empty, but having ideas and discussions spread all around doesn't really help me track down all pending things.

So, if you want (e.g. re: standard library and symbol aliases) any idea or suggestion is more than 100% welcome! :)

https://github.com/arturo-lang/arturo/discussions/categories/ideas

Good morning from Spain!