Giter VIP home page Giter VIP logo

luaextended's Introduction

What is this?

LuaExtended is a syntax definition and snippet package for Sublime Text 3.

Package Control license GitHub release GitHub stars

Features

As of right now, LuaExtended contains the following improvements over the default Lua package:

  • Indentation of repeat until loops fixed

  • Indentation of table definitions fixed

  • Improved syntax definition structure for easier future work on more fixes

  • error calls have red-highlighted strings

  • Completions include the full standard library, including parameter names with tab stops

  • Completions also include Lua keywords

  • New snippets:

    • New loop snippets (while and repeat)

    • Improved indentation of for snippets, synced variable name tab stops

    • ++ (expands the current line into the form of line = line + 1, ignoring inline comments and whitespace)

    • += and -=

    • dfun, an LDoc-style documented function snippet

    • if, elseif and else

    • if~, if=, and their elseif counterparts, expanding to if x ~= y then ... and similar

    • Most snippets also handle selection, meaning you can e.g. apply while on a block of code which will then become the body of the while loop

  • Function calls (including object method invocations foo:bar() and syntactic sugar like foo { bar }) are highlighted properly

  • Anonymous function definitions are highlighted properly (arguments are formatted)

  • Restructured indent settings

    • do end blocks are indented properly

  • All features are grouped under the source.luae scope, so that they don't interfere with the default Lua package

Installation

You can now use Package Control to install LuaExtended. Simply type "install" in the Command Palette (Ctrl + Shift + P) to find the Package Control: Install Package command. Wait for the repository lists to load

and search for 'LuaExtended'. Alternatively, you can clone this repository into your Data/User folder (either in the install directory, in %appdata%/Sublime Text 3 on Windoze, or wherever else other environments put it).

LuaExtended and Linters

If you are using a SublimeLinter3-based linter such as SublimeLinter-lua, you will need to modify your settings to get LuaExtended linting to work.

Navigate to Preferences > Package Settings

Find SublimeLinter in the list and open its "Settings - User"

The settings file is of the JSON format, so look for the line that says "syntax_map": {

You will need to add a binding that tells SublimeLinter to lint LuaExtended just like Lua. This is done by adding a line that says "luaextended": "lua",. Don't worry about the alphabetical order of the entries, SublimeLinter will sort them on next reload.

And there you go! Try opening a *.luae, *.ext.lua or *.extended.lua file and see whether linting works. If it for some reason doesn't work, read the tutorial again and check that you've followed it to the point. Try restarting Sublime before opening an issue!

luaextended's People

Contributors

internetunexplorer avatar viluon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

luaextended's Issues

More Documented Snippets

We already have dfun, but what about drepeat or dfor? Programmers are all too often too lazy to comment their code on their own, this would mildly force them to do so (there's always the option to stick to the original snippets).

Indentation Problems

I have used re-indent on previously written lua file it did failed to indent properly elseif blocks and braces at times
So I used solution mentioned in this
it seems issue is in "Indent.tmPreferences" file I fixed it and working fine now.

Concatenated error highlighting

If the string inside of the error call is broken up via concatenation, the highlighting does not carry through:

Also, if the error call doesn't have parentheses around the string, it is not colored at all:

Wrong Indentation with Statements

foo( something, something_else )

Will indent the following line one more tab (because of the else). This also holds for comments!

Code Conversion Snippets

Sublime Text 3 snippets have the option to access the $SELECTION variable, making them suitable for transforming selected text. There are cases when you would like to convert a for loop to a while loop, for example. Would it be too hard to implement snippets for that?

Is this syntax compatible with lua-language-server?

Hi there ๐Ÿ‘‹. The base scope of this syntax is source.luae. The default syntax's base scope is source.lua. What are the differences between the two? Perhaps more to the point, is this syntax compatible with lua-language-server? https://github.com/sumneko/lua-language-server

I'm maintaining a helper package for that server here: https://github.com/sublimelsp/LSP-lua. It only accounts for the default syntax. If this package is indeed compatible with this language server:

  • Should the syntax's base scope in this package be renamed to source.lua?
  • Or should LSP-lua account for an additional base scope source.luae?

Function indentation error

The GIF below was taken in a completely blank file, and the same keystrokes were used for both functions, however the result is... inconsistent.

Function Definition Highlighting Not Triggered with Newlines


Any newlines in the function definition will, while being correct syntactically, break the highlighting, because the regex is only matched against a single line. This means the function definition rule will have to be rewritten and split to form its own scope.

Wrong Regex for error() Strings

The scope responsible for highlighting error strings matches with regular strings in the file if error is defined as a variable:

Issue with new function scope

The new function scope merged from #9 seems to work great for functions, however my custom syntax pack no longer works as a result of the main scope not being used.

If a function definition precedes my class declaration, my syntax theme fails to pick it up - this is not the case with traditional Lua (hence I believe it is a LuaExtended issue, and not something I am doing incorrectly).

This is my syntax context:

  main:
    - match: "\\b(class|extends|mixin|alias)\\b"
      scope: keyword
      push: class-string-declaration

    - match: "\\b(abstract)\\b\\s+(?=class)\\b"
      scope: keyword

    - match: "\\b(configureConstructor)\\b(?=(\\w+))"
      scope: keyword

    - include: Packages/LuaExtended/LuaExtended.sublime-syntax

This does not work if a function is defined above the class declaration. Replacing 'LuaExtended' with 'Lua', fixes the issue but at the expense of losing the benefits of LuaExtended.

Screenshots:

Doesn't work

Does work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.