teal-language / vim-teal Goto Github PK
View Code? Open in Web Editor NEWTeal language support for Vim
License: MIT License
Teal language support for Vim
License: MIT License
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.
do
if (
condition
) then
print("foo")
end
end
gets auto formatted to
do
if (
condition
) then
print("foo")
end
end
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"
}
if
statements with parentheses are not getting indented:if true then
if (
true or false
) then
print("hello")
end
end
local x = FUNCTION
local y = {}
gets auto formatted to
local x = FUNCTION
local y = {}
when ignorecase
is set
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.
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
This is currently due to the tealTableConstructor
group being allowed to contain type annotations so they take priority over method call highlighting. Hopefully with the framework for generating syntax groups that I worked on this can be an easy fix.
example:
local t = {("foo"):reverse()}
Pressing the Return key after typing the following code does not trigger the creation of an end
token:
local Tree = record<X>
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.
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
Example:
-- get highlighted as types
-- vvvvvvvvv
local function foo(a: string, b: function(): (string), c: string)
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.