GithubHelp home page GithubHelp logo

teal-language / vim-teal Goto Github PK

View Code? Open in Web Editor NEW
32.0 4.0 5.0 226 KB

Teal language support for Vim

License: MIT License

Vim Script 100.00%
vim teal linter syntax-highlighting ale vim-plugin lua

vim-teal's Introduction

vim-teal

This plugin provides Teal language support for Vim.

Features

  • Syntax highlighting
  • Automatic indentation
  • Linting (requires ALE)
  • Automatic insertion of end tokens (requires vim-endwise)
  • :compiler support

Install

Using vim-plug:

" Teal language support
Plug 'teal-language/vim-teal'

" Optional dependencies; will be loaded on-demand when editing Teal files
Plug 'dense-analysis/ale', { 'for': 'teal' }
Plug 'tpope/vim-endwise', { 'for': 'teal' }

You should also make sure that the Teal compiler is available in your PATH:

luarocks install tl

Contributors

Contributions are greatly appreciated! Feel free to fork this repository and open a pull request on GitHub.

vim-teal's People

Contributors

euclidianace avatar pdesaulniers avatar ryansquared avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

vim-teal's Issues

Indentation File

Opening an issue to hold myself accountable.

One of the main issues is that anything within a type annotation should not change the indent level:
In partucular

local foo = record
    bar: function(function(): (number)): string
    baz: function(): number
    c: string
end

when auto formatted with =G produces something like

local foo = record
    bar: function(function(): (number)): string
            baz: function(): number
                c:string
            end

Uncorrect ALE linting

Hello. I use NVIM v0.8.3 and tl 0.15.1+dev. tl buid is successful for my project. But there is some broken highligts
2023-03-06-183516_5760x2160_scrot

vim-endwise support

It would be nice to add support for vim-endwise. Maybe we could create a plugin/teal.vim file with the following content (or something similar):

autocmd FileType teal
    \ let b:endwise_addition = 'end' |
    \ let b:endwise_words = 'function,do,then,record,enum' |
    \ let b:endwise_pattern = '^\s*\zs\%(\%(local\s\+\)\=function\)\>\%(.*\<end\>\)\@!\|\<\%(then\|do\|record\|enum\)\ze\s*$' |
    \ let b:endwise_syngroups = '???' " I'm not sure about the syntax's group names anymore

Remaining issues with indent script

  1. In tl.tl, there's a line that says
local standard_library: {string:Type} = {

The code that follows this huge table assignment (for _, t in pairs(standard_library) do, etc) is indented too far to the right.

I think this is because there's a variable name FUNCTION which increases the indentation. Here's a reduced test case:

local x = {
   y = FUNCTION,
      z = "hello"
   }
  1. It seems like multiline if statements with parentheses are not getting indented:
if true then
   if (
      true or false
   ) then
   print("hello")
end
end

Specific colorscheme support?

I personally use the Dracula colorscheme which has a specification for how certain things like type annotations should be colored and the default highlight groups can't support it.
Maybe this could be supported with a ftplugin?

if g:colors_name == "dracula"
	hi! link tealSelf DraculaPurpleItalic
	" etc ...
endif

Or should this be done by the colorscheme itself? As I know dracula definitely has filetype plugins to set colors.
I feel as though this sort of thing should be maintained here since the highlight groups may change subtly in the future and it could be a hassle to pull request a bunch of colorscheme repos.

I'm currently just doing this in my init.vim which feels wrong.

indent: large files are problematic

The current functions we are using to check for indentation have timeouts that actually timeout on large files such as tl.tl

We should make some effort to optimize the indent file so that these timeouts are within the scope or find a way to extend these timeouts.

syntax: Methods and type annotations are confused in some places

Due to methods foo:bar() and type annotations local foo: bar both using colons, it can be difficult do distinguish them. This is mostly handled correctly, except in the following case:

local function foo(): function()

end

where the function() in the type annotation is highlighted as if it were a function call rather than a type annotation.

This is currently due to how the tealFunctionSignature group is defined since it uses keepend to have the groups it contains contain the boundaries of itself. In addition, keepend and nextgroup don't play nice together.

So the plan is to probably redefine how function signatures are handled, to allow for a nextgroup to prioritize the type annotation highlight.

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.