Skip to content

Commit

Permalink
Updated vim.d.tl to have more content
Browse files Browse the repository at this point in the history
  • Loading branch information
svermeulen committed Mar 27, 2022
1 parent 4490c60 commit b2c42aa
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 5 deletions.
57 changes: 56 additions & 1 deletion types/neovim/template
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ global record vim
-- mode: function(): Mode
-- ...
-- end

-- TODO:
-- vim.opt
-- vim.opt_global
-- vim.opt_local
-- vim.treesitter

fn: {string:function(...: any): (any)}
cmd: function(cmd: string)
call: function(func: string, ...: any)
call: function(string, ...: any): any

enum Mode
"n" -- Normal
Expand Down Expand Up @@ -65,6 +73,7 @@ global record vim
end
end
notify: function(msg: string, log_level: integer, opts: table)
notify_once: function(msg:string, level:integer, opt:table)
paste: function({string}, integer): boolean
schedule_wrap: function(function): function
deep_equal: function(any, any): boolean
Expand Down Expand Up @@ -139,6 +148,52 @@ global record vim
end
regex: function(string): Regex

diff: function(a:string, b:string):string
-- TODO
-- diff: function(a:string, b:string, options:DiffOptions):string | {integer}

record VersionInfo
api_compatible:integer
api_level:integer
api_prerelease:integer
major:integer
minor:integer
patch:integer
end

version:function():VersionInfo

uri_from_bufnr:function(bufnr:integer):string
uri_from_fname:function(path:string):string
uri_to_bufnr:function(uri:string):integer
uri_to_fname:function(uri:string):string

pretty_print:function(obj:any):string

region:function(bufnr:integer, pos1:{integer}, pos2:{integer}, regtype:string, inclusive:boolean):{integer:{integer}}

record highlight
-- TODO - replace opts table with record
on_yank: function(opts:table)
range: function(bufnr:integer, ns:string, higroup:string, start:{integer}, finish:{integer}, rtype:string, inclusive:boolean)
end

record filetype
-- TODO - replace table with options record
add: function(filetypes:table)

match: function(name:string, bufnr:integer)
end

record mpack
encode: function(obj:any):string
decode: function(str:string):any
end

record spell
check: function(str:string):{{string | integer}}
end

-- TODO: these are a pitiful approximation of luv's types
-- once Teal has some form of type inheritance/composition and luv.d.tl is written
-- just steal from that
Expand Down Expand Up @@ -216,7 +271,6 @@ global record vim
fs_mkdir: function(string, integer, function(string, boolean)): boolean | Dir, string, string
end

call: function(string, ...: any): any
in_fast_event: function(): boolean

type NIL = record userdata end -- special nil for filling tables
Expand Down Expand Up @@ -413,6 +467,7 @@ global record vim
end

g: {string:any}
go: {string:any}
t: {string:any}
v: {string:any}
env: {string:any}
Expand Down
71 changes: 67 additions & 4 deletions types/neovim/vim.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ global record vim
-- mode: function(): Mode
-- ...
-- end

-- TODO:
-- vim.opt
-- vim.opt_global
-- vim.opt_local
-- vim.treesitter

fn: {string:function(...: any): (any)}
cmd: function(cmd: string)
call: function(func: string, ...: any)
call: function(string, ...: any): any

enum Mode
"n" -- Normal
Expand Down Expand Up @@ -65,6 +73,7 @@ global record vim
end
end
notify: function(msg: string, log_level: integer, opts: table)
notify_once: function(msg:string, level:integer, opt:table)
paste: function({string}, integer): boolean
schedule_wrap: function(function): function
deep_equal: function(any, any): boolean
Expand Down Expand Up @@ -139,6 +148,52 @@ global record vim
end
regex: function(string): Regex

diff: function(a:string, b:string):string
-- TODO
-- diff: function(a:string, b:string, options:DiffOptions):string | {integer}

record VersionInfo
api_compatible:integer
api_level:integer
api_prerelease:integer
major:integer
minor:integer
patch:integer
end

version:function():VersionInfo

uri_from_bufnr:function(bufnr:integer):string
uri_from_fname:function(path:string):string
uri_to_bufnr:function(uri:string):integer
uri_to_fname:function(uri:string):string

pretty_print:function(obj:any):string

region:function(bufnr:integer, pos1:{integer}, pos2:{integer}, regtype:string, inclusive:boolean):{integer:{integer}}

record highlight
-- TODO - replace opts table with record
on_yank: function(opts:table)
range: function(bufnr:integer, ns:string, higroup:string, start:{integer}, finish:{integer}, rtype:string, inclusive:boolean)
end

record filetype
-- TODO - replace table with options record
add: function(filetypes:table)

match: function(name:string, bufnr:integer)
end

record mpack
encode: function(obj:any):string
decode: function(str:string):any
end

record spell
check: function(str:string):{{string | integer}}
end

-- TODO: these are a pitiful approximation of luv's types
-- once Teal has some form of type inheritance/composition and luv.d.tl is written
-- just steal from that
Expand Down Expand Up @@ -216,7 +271,6 @@ global record vim
fs_mkdir: function(string, integer, function(string, boolean)): boolean | Dir, string, string
end

call: function(string, ...: any): any
in_fast_event: function(): boolean

type NIL = record userdata end -- special nil for filling tables
Expand Down Expand Up @@ -413,6 +467,7 @@ global record vim
end

g: {string:any}
go: {string:any}
t: {string:any}
v: {string:any}
env: {string:any}
Expand Down Expand Up @@ -659,6 +714,8 @@ global record vim
spell: boolean
statusline: string
stl: string
ve: string
virtualedit: string
wfh: boolean
wfw: boolean
winbl: number
Expand All @@ -675,11 +732,11 @@ global record vim
record api
--[[
API version Information
neovim version: 0.6.1
neovim version: 0.7.0
compatible: 0
level: 8
prerelease: false
level: 9
prerelease: true
--]]

--[[
Expand All @@ -696,13 +753,16 @@ global record vim
none of the above -> any
--]]

nvim_add_user_command: function(string--[[String]], any--[[Object]], {string:any}--[[Dictionary]])--[[void]]
nvim_buf_add_highlight: function(integer--[[Buffer]], integer--[[Integer]], string--[[String]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]]): integer--[[Integer]]
nvim_buf_add_user_command: function(integer--[[Buffer]], string--[[String]], any--[[Object]], {string:any}--[[Dictionary]])--[[void]]
nvim_buf_attach: function(integer--[[Buffer]], boolean--[[Boolean]], {string:any}--[[Dictionary]]): boolean--[[Boolean]]
nvim_buf_call: function(integer--[[Buffer]], any--[[LuaRef]]): any--[[Object]]
nvim_buf_clear_namespace: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]], integer--[[Integer]])--[[void]]
nvim_buf_del_extmark: function(integer--[[Buffer]], integer--[[Integer]], integer--[[Integer]]): boolean--[[Boolean]]
nvim_buf_del_keymap: function(integer--[[Buffer]], string--[[String]], string--[[String]])--[[void]]
nvim_buf_del_mark: function(integer--[[Buffer]], string--[[String]]): boolean--[[Boolean]]
nvim_buf_del_user_command: function(integer--[[Buffer]], string--[[String]])--[[void]]
nvim_buf_del_var: function(integer--[[Buffer]], string--[[String]])--[[void]]
nvim_buf_delete: function(integer--[[Buffer]], {string:any}--[[Dictionary]])--[[void]]
nvim_buf_detach: function(integer--[[Buffer]]): boolean--[[Boolean]]
Expand Down Expand Up @@ -738,6 +798,7 @@ global record vim
nvim_del_current_line: function()--[[void]]
nvim_del_keymap: function(string--[[String]], string--[[String]])--[[void]]
nvim_del_mark: function(string--[[String]]): boolean--[[Boolean]]
nvim_del_user_command: function(string--[[String]])--[[void]]
nvim_del_var: function(string--[[String]])--[[void]]
nvim_echo: function(any--[[Array]], boolean--[[Boolean]], {string:any}--[[Dictionary]])--[[void]]
nvim_err_write: function(string--[[String]])--[[void]]
Expand Down Expand Up @@ -767,6 +828,7 @@ global record vim
nvim_get_namespaces: function(): {string:any}--[[Dictionary]]
nvim_get_option: function(string--[[String]]): any--[[Object]]
nvim_get_option_info: function(string--[[String]]): {string:any}--[[Dictionary]]
nvim_get_option_value: function(string--[[String]], {string:any}--[[Dictionary]]): any--[[Object]]
nvim_get_proc: function(integer--[[Integer]]): any--[[Object]]
nvim_get_proc_children: function(integer--[[Integer]]): any--[[Array]]
nvim_get_runtime_file: function(string--[[String]], boolean--[[Boolean]]): {string}--[[ArrayOf(String)]]
Expand Down Expand Up @@ -800,6 +862,7 @@ global record vim
nvim_set_hl: function(integer--[[Integer]], string--[[String]], {string:any}--[[Dictionary]])--[[void]]
nvim_set_keymap: function(string--[[String]], string--[[String]], string--[[String]], {string:any}--[[Dictionary]])--[[void]]
nvim_set_option: function(string--[[String]], any--[[Object]])--[[void]]
nvim_set_option_value: function(string--[[String]], any--[[Object]], {string:any}--[[Dictionary]])--[[void]]
nvim_set_var: function(string--[[String]], any--[[Object]])--[[void]]
nvim_set_vvar: function(string--[[String]], any--[[Object]])--[[void]]
nvim_strwidth: function(string--[[String]]): integer--[[Integer]]
Expand Down

0 comments on commit b2c42aa

Please sign in to comment.