├── .github └── workflows │ └── release.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build.hxml ├── doc └── example_plugin.txt ├── libs.hxml ├── lua └── example_plugin │ └── init.lua └── src ├── Main.hx └── import.hx /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | tests: 8 | strategy: 9 | matrix: 10 | # os: [ubuntu-latest, windows-latest] 11 | os: [ubuntu-latest] 12 | runs-on: ${{ matrix.os }} 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Setup haxe 16 | uses: krdlab/setup-haxe@v1 17 | with: 18 | haxe-version: 4.2.5 19 | - name: Build haxe code 20 | run: | 21 | haxe -version 22 | haxelib install --always libs.hxml 23 | haxe build.hxml 24 | - name: Install Neovim 25 | shell: bash 26 | run: | 27 | wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.deb -O /tmp/nvim.deb 28 | sudo dpkg -i /tmp/nvim.deb 29 | - name: Run Tests 30 | run: | 31 | nvim --version 32 | [ ! -d tests ] && exit 0 33 | nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}" 34 | docs: 35 | runs-on: ubuntu-latest 36 | needs: tests 37 | if: ${{ github.ref == 'refs/heads/main' }} 38 | steps: 39 | - uses: actions/checkout@v3 40 | with: 41 | ref: ${{ github.head_ref }} 42 | - name: panvimdoc 43 | uses: kdheepak/panvimdoc@main 44 | with: 45 | vimdoc: example_plugin 46 | version: "Neovim >= 0.8.0" 47 | demojify: true 48 | treesitter: true 49 | - name: Push changes 50 | uses: stefanzweifel/git-auto-commit-action@v4 51 | with: 52 | branch: main 53 | commit_message: "chore(build): auto-generate vimdoc" 54 | commit_user_name: "github-actions[bot]" 55 | commit_user_email: "github-actions[bot]@users.noreply.github.com" 56 | commit_author: "github-actions[bot] " 57 | release: 58 | name: release 59 | if: ${{ github.ref == 'refs/heads/main' }} 60 | needs: 61 | - docs 62 | - tests 63 | runs-on: ubuntu-latest 64 | steps: 65 | - uses: google-github-actions/release-please-action@v3 66 | id: release 67 | with: 68 | release-type: simple 69 | package-name: example_plugin 70 | - uses: actions/checkout@v3 71 | - name: tag stable versions 72 | if: ${{ steps.release.outputs.release_created }} 73 | run: | 74 | git config user.name github-actions[bot] 75 | git config user.email github-actions[bot]@users.noreply.github.com 76 | git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" 77 | git tag -d stable || true 78 | git push origin :stable || true 79 | git tag -a stable -m "Last Stable Release" 80 | git push origin stable 81 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 (2023-02-18) 4 | 5 | 6 | ### Features 7 | 8 | * initial code commit ([5021148](https://github.com/danielo515/haxe-nvim-example-plugin/commit/5021148d5efe94d188e894ccc41b224c709150be)) 9 | * release ci flow ([5be67e1](https://github.com/danielo515/haxe-nvim-example-plugin/commit/5be67e1b9f9f238aea4c2dbe484fdfa4fda2f803)) 10 | 11 | 12 | ### Bug Fixes 13 | 14 | * haxe version ([163231f](https://github.com/danielo515/haxe-nvim-example-plugin/commit/163231f4843a170f43e43b3ce52318f2cb6b8b58)) 15 | * instaall on ci ([09fa62b](https://github.com/danielo515/haxe-nvim-example-plugin/commit/09fa62b76a389d01170c648885f083e727916f21)) 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Daniel Rodríguez Rivero 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # haxe-nvim example_plugin 2 | 3 | This is a template project to create NeoVim plugins using [haxe](https://haxe.org/) via the [haxe-nvim](https://github.com/danielo515/haxe-nvim) library. 4 | 5 | ## How to use this template 6 | 7 | There are several simple ways to use this template: 8 | - You can just create a new repository on github and select this repository as template for your new project. 9 | - Alternatively you can just clone this repository and remove the `.git` folder 10 | - or you can download the zip containing the source code of this repository and unzip it 11 | 12 | It is all up to you! 13 | 14 | Once you did one of the previous steps, I recommend the following: 15 | 16 | 1. run `haxelib install libs.hxml` so you get the required libraries and dependencies 17 | 1. run `haxe build.hxml` to check that everything compiles and works out of the box 18 | 1. rename all appearances of example_plugin to the name you want to give you your plugin 19 | 1. explore `src/Main.hx` to get an idea of how you can start writing your own plugin 20 | 1. delete the parts of this readme that do not apply to your plugin, like this first sections 21 | 1. update the installation instructions and documentation to match those of your plugins 22 | 23 | ## Workflow 24 | 25 | Just add files and functions to the `src` folder. 26 | I recommend you to avoid inheritance and subclassing because those are not very good supported 27 | in the Lua target. I suggest you to focus and take advantage of the **many functional** capabilities 28 | Haxe has, such as: 29 | - lambas `() -> ` 30 | - module level static functions (this will save you a lot of boilerplate) 31 | - static extensions (we include some by default) 32 | 33 | You must commit the generated Lua code. Most (if not all) NeoVim plugin managers will just clone 34 | your plugin repository to the required NeoVim folders, and they will expect your plugin repository 35 | to contain all the required plugin files, which in the case of haxe-nvim projects is the `lua` folder. 36 | 37 | When you want to test your plugin, just build it using `haxe build.hxml` and then test it in NeoVim. 38 | One of the simplest ways of testing this plugin in NeoVim is using packer and adding your local 39 | path in your filesystem where your plugin is just like any other NeoVim plugin. Something like: 40 | 41 | ```lua 42 | use { 43 | '~/GIT/your-plugin-folder', 44 | config = function() 45 | require "example_plugin" 46 | end, 47 | } 48 | ``` 49 | 50 | ## Differences from regular Haxe projects 51 | 52 | If you are already familiar with Haxe you may feel there are some differences between this project 53 | and regular Haxe projects. 54 | Note that NeoVim has some very specific requirements and the regular Haxe ways of doing things not always work. 55 | For that reason, haxe-nvim not only includes bindings to (almost all) NeoVim APIs, but also several 56 | macros and function helpers that work better within the NeoVim scope. 57 | Defaults of this example project have been chosen because they have been proven reliable and to work 58 | good inisde NeoVim plugins. That includes the default opens(take a look at `src/import.hx`), 59 | the provided helper functions and even the Macros. Everything was tested and is being used in my 60 | personal (and main) NeoVim configuration, and let me tell you that making all that work properly was 61 | not a trivial task! 62 | 63 | ``` 64 | | Your plugin Readme should start right below here | 65 | ⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄ 66 | ``` 67 | # example_plugin 68 | 69 | ## How to install this plugin 70 | 71 | This NeoVim plugin can be installed just like any other plugin. Use your plugin manager of choice. 72 | We provide example instructions for [packer.nvim](https://github.com/wbthomason/packer.nvim) 73 | 74 | ### Using packer 75 | 76 | ```lua 77 | use { 78 | 'danielo515/haxe-nvim-example-plugin', 79 | config = function() 80 | require "example_plugin" 81 | end, 82 | } 83 | ``` 84 | -------------------------------------------------------------------------------- /build.hxml: -------------------------------------------------------------------------------- 1 | libs.hxml 2 | --macro nullSafety("vim", Strict) 3 | 4 | -D analyzer-module 5 | -D analyzer-optimize 6 | -D analyzer-user-var-fusion 7 | -D analyzer-const_propagation 8 | -D analyzer-copy_propagation 9 | -D analyzer-local_dce 10 | -D analyzer-fusion 11 | -D analyzer-purity_inference 12 | 13 | -D lua-vanilla 14 | -D luajit 15 | 16 | 17 | -cp src 18 | -dce full 19 | 20 | --each 21 | 22 | --main Main 23 | --lua lua/example_plugin/init.lua 24 | -------------------------------------------------------------------------------- /doc/example_plugin.txt: -------------------------------------------------------------------------------- 1 | *example_plugin.txt* For Neovim >= 0.8.0 Last change: 2023 February 18 2 | 3 | ============================================================================== 4 | Table of Contents *example_plugin-table-of-contents* 5 | 6 | 1. haxe-nvim example_plugin |example_plugin-haxe-nvim-example_plugin| 7 | - How to use this template |example_plugin-how-to-use-this-template| 8 | - Workflow |example_plugin-workflow| 9 | - Differences from regular Haxe projects|example_plugin-differences-from-regular-haxe-projects| 10 | 2. example_plugin |example_plugin-example_plugin| 11 | - How to install this plugin |example_plugin-how-to-install-this-plugin| 12 | 13 | ============================================================================== 14 | 1. haxe-nvim example_plugin *example_plugin-haxe-nvim-example_plugin* 15 | 16 | This is a template project to create NeoVim plugins using haxe 17 | via the haxe-nvim 18 | library. 19 | 20 | HOW TO USE THIS TEMPLATE *example_plugin-how-to-use-this-template* 21 | 22 | There are several simple ways to use this template: - You can just create a new 23 | repository on github and select this repository as template for your new 24 | project. - Alternatively you can just clone this repository and remove the 25 | `.git` folder - or you can download the zip containing the source code of this 26 | repository and unzip it 27 | 28 | It is all up to you! 29 | 30 | Once you did one of the previous steps, I recommend the following: 31 | 32 | 33 | 1. run `haxelib install libs.hxml` so you get the required libraries and dependencies 34 | 2. run `haxe build.hxml` to check that everything compiles and works out of the box 35 | 3. rename all appearances of example_plugin to the name you want to give you your plugin 36 | 4. explore `src/Main.hx` to get an idea of how you can start writing your own plugin 37 | 5. delete the parts of this readme that do not apply to your plugin, like this first sections 38 | 6. update the installation instructions and documentation to match those of your plugins 39 | 40 | 41 | WORKFLOW *example_plugin-workflow* 42 | 43 | Just add files and functions to the `src` folder. I recommend you to avoid 44 | inheritance and subclassing because those are not very good supported in the 45 | Lua target. I suggest you to focus and take advantage of the **many 46 | functional** capabilities Haxe has, such as: - lambas `() ->` - module level 47 | static functions (this will save you a lot of boilerplate) - static extensions 48 | (we include some by default) 49 | 50 | You must commit the generated Lua code. Most (if not all) NeoVim plugin 51 | managers will just clone your plugin repository to the required NeoVim folders, 52 | and they will expect your plugin repository to contain all the required plugin 53 | files, which in the case of haxe-nvim projects is the `lua` folder. 54 | 55 | When you want to test your plugin, just build it using `haxe build.hxml` and 56 | then test it in NeoVim. One of the simplest ways of testing this plugin in 57 | NeoVim is using packer and adding your local path in your filesystem where your 58 | plugin is just like any other NeoVim plugin. Something like: 59 | 60 | >lua 61 | use { 62 | '~/GIT/your-plugin-folder', 63 | config = function() 64 | require "example_plugin" 65 | end, 66 | } 67 | < 68 | 69 | 70 | DIFFERENCES FROM REGULAR HAXE PROJECTS*example_plugin-differences-from-regular-haxe-projects* 71 | 72 | If you are already familiar with Haxe you may feel there are some differences 73 | between this project and regular Haxe projects. Note that NeoVim has some very 74 | specific requirements and the regular Haxe ways of doing things not always 75 | work. For that reason, haxe-nvim not only includes bindings to (almost all) 76 | NeoVim APIs, but also several macros and function helpers that work better 77 | within the NeoVim scope. Defaults of this example project have been chosen 78 | because they have been proven reliable and to work good inisde NeoVim plugins. 79 | That includes the default opens(take a look at `src/import.hx`), the provided 80 | helper functions and even the Macros. Everything was tested and is being used 81 | in my personal (and main) NeoVim configuration, and let me tell you that making 82 | all that work properly was not a trivial task! 83 | 84 | > 85 | | Your plugin Readme should start right below here | 86 | ⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄ 87 | < 88 | 89 | 90 | ============================================================================== 91 | 2. example_plugin *example_plugin-example_plugin* 92 | 93 | HOW TO INSTALL THIS PLUGIN *example_plugin-how-to-install-this-plugin* 94 | 95 | This NeoVim plugin can be installed just like any other plugin. Use your plugin 96 | manager of choice. We provide example instructions for packer.nvim 97 | 98 | 99 | USING PACKER ~ 100 | 101 | >lua 102 | use { 103 | 'danielo515/haxe-nvim-example-plugin', 104 | config = function() 105 | require "example_plugin" 106 | end, 107 | } 108 | < 109 | 110 | 111 | Generated by panvimdoc 112 | 113 | vim:tw=78:ts=8:noet:ft=help:norl: 114 | -------------------------------------------------------------------------------- /libs.hxml: -------------------------------------------------------------------------------- 1 | --library haxe-nvim 2 | --library safety:1.1.2 3 | -------------------------------------------------------------------------------- /lua/example_plugin/init.lua: -------------------------------------------------------------------------------- 1 | local _hx_hidden = {__id__=true, hx__closures=true, super=true, prototype=true, __fields__=true, __ifields__=true, __class__=true, __properties__=true, __fields__=true, __name__=true} 2 | 3 | _hx_array_mt = { 4 | __newindex = function(t,k,v) 5 | local len = t.length 6 | t.length = k >= len and (k + 1) or len 7 | rawset(t,k,v) 8 | end 9 | } 10 | 11 | function _hx_is_array(o) 12 | return type(o) == "table" 13 | and o.__enum__ == nil 14 | and getmetatable(o) == _hx_array_mt 15 | end 16 | 17 | 18 | 19 | function _hx_tab_array(tab, length) 20 | tab.length = length 21 | return setmetatable(tab, _hx_array_mt) 22 | end 23 | 24 | 25 | 26 | function _hx_print_class(obj, depth) 27 | local first = true 28 | local result = '' 29 | for k,v in pairs(obj) do 30 | if _hx_hidden[k] == nil then 31 | if first then 32 | first = false 33 | else 34 | result = result .. ', ' 35 | end 36 | if _hx_hidden[k] == nil then 37 | result = result .. k .. ':' .. _hx_tostring(v, depth+1) 38 | end 39 | end 40 | end 41 | return '{ ' .. result .. ' }' 42 | end 43 | 44 | function _hx_print_enum(o, depth) 45 | if o.length == 2 then 46 | return o[0] 47 | else 48 | local str = o[0] .. "(" 49 | for i = 2, (o.length-1) do 50 | if i ~= 2 then 51 | str = str .. "," .. _hx_tostring(o[i], depth+1) 52 | else 53 | str = str .. _hx_tostring(o[i], depth+1) 54 | end 55 | end 56 | return str .. ")" 57 | end 58 | end 59 | 60 | function _hx_tostring(obj, depth) 61 | if depth == nil then 62 | depth = 0 63 | elseif depth > 5 then 64 | return "<...>" 65 | end 66 | 67 | local tstr = _G.type(obj) 68 | if tstr == "string" then return obj 69 | elseif tstr == "nil" then return "null" 70 | elseif tstr == "number" then 71 | if obj == _G.math.POSITIVE_INFINITY then return "Infinity" 72 | elseif obj == _G.math.NEGATIVE_INFINITY then return "-Infinity" 73 | elseif obj == 0 then return "0" 74 | elseif obj ~= obj then return "NaN" 75 | else return _G.tostring(obj) 76 | end 77 | elseif tstr == "boolean" then return _G.tostring(obj) 78 | elseif tstr == "userdata" then 79 | local mt = _G.getmetatable(obj) 80 | if mt ~= nil and mt.__tostring ~= nil then 81 | return _G.tostring(obj) 82 | else 83 | return "" 84 | end 85 | elseif tstr == "function" then return "" 86 | elseif tstr == "thread" then return "" 87 | elseif tstr == "table" then 88 | if obj.__enum__ ~= nil then 89 | return _hx_print_enum(obj, depth) 90 | elseif obj.toString ~= nil and not _hx_is_array(obj) then return obj:toString() 91 | elseif _hx_is_array(obj) then 92 | if obj.length > 5 then 93 | return "[...]" 94 | else 95 | local str = "" 96 | for i=0, (obj.length-1) do 97 | if i == 0 then 98 | str = str .. _hx_tostring(obj[i], depth+1) 99 | else 100 | str = str .. "," .. _hx_tostring(obj[i], depth+1) 101 | end 102 | end 103 | return "[" .. str .. "]" 104 | end 105 | elseif obj.__class__ ~= nil then 106 | return _hx_print_class(obj, depth) 107 | else 108 | local buffer = {} 109 | local ref = obj 110 | if obj.__fields__ ~= nil then 111 | ref = obj.__fields__ 112 | end 113 | for k,v in pairs(ref) do 114 | if _hx_hidden[k] == nil then 115 | _G.table.insert(buffer, _hx_tostring(k, depth+1) .. ' : ' .. _hx_tostring(obj[k], depth+1)) 116 | end 117 | end 118 | 119 | return "{ " .. table.concat(buffer, ", ") .. " }" 120 | end 121 | else 122 | _G.error("Unknown Lua type", 0) 123 | return "" 124 | end 125 | end 126 | 127 | function _hx_error(obj) 128 | if obj.value then 129 | _G.print("runtime error:\n " .. _hx_tostring(obj.value)); 130 | else 131 | _G.print("runtime error:\n " .. tostring(obj)); 132 | end 133 | 134 | if _G.debug and _G.debug.traceback then 135 | _G.print(debug.traceback()); 136 | end 137 | end 138 | 139 | 140 | local function _hx_obj_newindex(t,k,v) 141 | t.__fields__[k] = true 142 | rawset(t,k,v) 143 | end 144 | 145 | local _hx_obj_mt = {__newindex=_hx_obj_newindex, __tostring=_hx_tostring} 146 | 147 | local function _hx_a(...) 148 | local __fields__ = {}; 149 | local ret = {__fields__ = __fields__}; 150 | local max = select('#',...); 151 | local tab = {...}; 152 | local cur = 1; 153 | while cur < max do 154 | local v = tab[cur]; 155 | __fields__[v] = true; 156 | ret[v] = tab[cur+1]; 157 | cur = cur + 2 158 | end 159 | return setmetatable(ret, _hx_obj_mt) 160 | end 161 | 162 | local function _hx_e() 163 | return setmetatable({__fields__ = {}}, _hx_obj_mt) 164 | end 165 | 166 | local function _hx_o(obj) 167 | return setmetatable(obj, _hx_obj_mt) 168 | end 169 | 170 | local function _hx_new(prototype) 171 | return setmetatable({__fields__ = {}}, {__newindex=_hx_obj_newindex, __index=prototype, __tostring=_hx_tostring}) 172 | end 173 | 174 | function _hx_field_arr(obj) 175 | res = {} 176 | idx = 0 177 | if obj.__fields__ ~= nil then 178 | obj = obj.__fields__ 179 | end 180 | for k,v in pairs(obj) do 181 | if _hx_hidden[k] == nil then 182 | res[idx] = k 183 | idx = idx + 1 184 | end 185 | end 186 | return _hx_tab_array(res, idx) 187 | end 188 | 189 | local _hxClasses = {} 190 | local Int = _hx_e(); 191 | local Dynamic = _hx_e(); 192 | local Float = _hx_e(); 193 | local Bool = _hx_e(); 194 | local Class = _hx_e(); 195 | local Enum = _hx_e(); 196 | 197 | local _hx_exports = _hx_exports or {} 198 | local Array = _hx_e() 199 | ___Main_Main_Fields_ = _hx_e() 200 | local Math = _hx_e() 201 | local String = _hx_e() 202 | local Std = _hx_e() 203 | __haxe_iterators_ArrayIterator = _hx_e() 204 | __haxe_iterators_ArrayKeyValueIterator = _hx_e() 205 | __lua_StringMap = _hx_e() 206 | __vim__TableTools_TableTools_Fields_ = _hx_e() 207 | __vim__VimTypes_LuaArray_Impl_ = _hx_e() 208 | __vim_Vimx = _hx_e() 209 | 210 | local _hx_bind, _hx_bit, _hx_staticToInstance, _hx_funcToField, _hx_maxn, _hx_print, _hx_apply_self, _hx_box_mr, _hx_bit_clamp, _hx_table, _hx_bit_raw 211 | local _hx_pcall_default = {}; 212 | local _hx_pcall_break = {}; 213 | 214 | Array.new = function() 215 | local self = _hx_new(Array.prototype) 216 | Array.super(self) 217 | return self 218 | end 219 | Array.super = function(self) 220 | _hx_tab_array(self, 0); 221 | end 222 | Array.prototype = _hx_e(); 223 | Array.prototype.concat = function(self,a) 224 | local _g = _hx_tab_array({}, 0); 225 | local _g1 = 0; 226 | while (_g1 < self.length) do 227 | local i = self[_g1]; 228 | _g1 = _g1 + 1; 229 | _g:push(i); 230 | end; 231 | local _g1 = 0; 232 | while (_g1 < a.length) do 233 | local i = a[_g1]; 234 | _g1 = _g1 + 1; 235 | _g:push(i); 236 | end; 237 | do return _g end 238 | end 239 | Array.prototype.join = function(self,sep) 240 | local tbl = ({}); 241 | local _g_current = 0; 242 | while (_g_current < self.length) do 243 | _g_current = _g_current + 1; 244 | _G.table.insert(tbl, Std.string(self[_g_current - 1])); 245 | end; 246 | do return _G.table.concat(tbl, sep) end 247 | end 248 | Array.prototype.pop = function(self) 249 | if (self.length == 0) then 250 | do return nil end; 251 | end; 252 | local ret = self[self.length - 1]; 253 | self[self.length - 1] = nil; 254 | self.length = self.length - 1; 255 | do return ret end 256 | end 257 | Array.prototype.push = function(self,x) 258 | self[self.length] = x; 259 | do return self.length end 260 | end 261 | Array.prototype.reverse = function(self) 262 | local tmp; 263 | local i = 0; 264 | while (i < Std.int(self.length / 2)) do 265 | tmp = self[i]; 266 | self[i] = self[(self.length - i) - 1]; 267 | self[(self.length - i) - 1] = tmp; 268 | i = i + 1; 269 | end; 270 | end 271 | Array.prototype.shift = function(self) 272 | if (self.length == 0) then 273 | do return nil end; 274 | end; 275 | local ret = self[0]; 276 | if (self.length == 1) then 277 | self[0] = nil; 278 | else 279 | if (self.length > 1) then 280 | self[0] = self[1]; 281 | _G.table.remove(self, 1); 282 | end; 283 | end; 284 | local tmp = self; 285 | tmp.length = tmp.length - 1; 286 | do return ret end 287 | end 288 | Array.prototype.slice = function(self,pos,_end) 289 | if ((_end == nil) or (_end > self.length)) then 290 | _end = self.length; 291 | else 292 | if (_end < 0) then 293 | _end = _G.math.fmod((self.length - (_G.math.fmod(-_end, self.length))), self.length); 294 | end; 295 | end; 296 | if (pos < 0) then 297 | pos = _G.math.fmod((self.length - (_G.math.fmod(-pos, self.length))), self.length); 298 | end; 299 | if ((pos > _end) or (pos > self.length)) then 300 | do return _hx_tab_array({}, 0) end; 301 | end; 302 | local ret = _hx_tab_array({}, 0); 303 | local _g = pos; 304 | local _g1 = _end; 305 | while (_g < _g1) do 306 | _g = _g + 1; 307 | ret:push(self[_g - 1]); 308 | end; 309 | do return ret end 310 | end 311 | Array.prototype.sort = function(self,f) 312 | local i = 0; 313 | local l = self.length; 314 | while (i < l) do 315 | local swap = false; 316 | local j = 0; 317 | local max = (l - i) - 1; 318 | while (j < max) do 319 | if (f(self[j], self[j + 1]) > 0) then 320 | local tmp = self[j + 1]; 321 | self[j + 1] = self[j]; 322 | self[j] = tmp; 323 | swap = true; 324 | end; 325 | j = j + 1; 326 | end; 327 | if (not swap) then 328 | break; 329 | end; 330 | i = i + 1; 331 | end; 332 | end 333 | Array.prototype.splice = function(self,pos,len) 334 | if ((len < 0) or (pos > self.length)) then 335 | do return _hx_tab_array({}, 0) end; 336 | else 337 | if (pos < 0) then 338 | pos = self.length - (_G.math.fmod(-pos, self.length)); 339 | end; 340 | end; 341 | len = Math.min(len, self.length - pos); 342 | local ret = _hx_tab_array({}, 0); 343 | local _g = pos; 344 | local _g1 = pos + len; 345 | while (_g < _g1) do 346 | _g = _g + 1; 347 | local i = _g - 1; 348 | ret:push(self[i]); 349 | self[i] = self[i + len]; 350 | end; 351 | local _g = pos + len; 352 | local _g1 = self.length; 353 | while (_g < _g1) do 354 | _g = _g + 1; 355 | local i = _g - 1; 356 | self[i] = self[i + len]; 357 | end; 358 | self.length = self.length - len; 359 | do return ret end 360 | end 361 | Array.prototype.toString = function(self) 362 | local tbl = ({}); 363 | _G.table.insert(tbl, "["); 364 | _G.table.insert(tbl, self:join(",")); 365 | _G.table.insert(tbl, "]"); 366 | do return _G.table.concat(tbl, "") end 367 | end 368 | Array.prototype.unshift = function(self,x) 369 | local len = self.length; 370 | local _g = 0; 371 | while (_g < len) do 372 | _g = _g + 1; 373 | local i = _g - 1; 374 | self[len - i] = self[(len - i) - 1]; 375 | end; 376 | self[0] = x; 377 | end 378 | Array.prototype.insert = function(self,pos,x) 379 | if (pos > self.length) then 380 | pos = self.length; 381 | end; 382 | if (pos < 0) then 383 | pos = self.length + pos; 384 | if (pos < 0) then 385 | pos = 0; 386 | end; 387 | end; 388 | local cur_len = self.length; 389 | while (cur_len > pos) do 390 | self[cur_len] = self[cur_len - 1]; 391 | cur_len = cur_len - 1; 392 | end; 393 | self[pos] = x; 394 | end 395 | Array.prototype.remove = function(self,x) 396 | local _g = 0; 397 | local _g1 = self.length; 398 | while (_g < _g1) do 399 | _g = _g + 1; 400 | local i = _g - 1; 401 | if (self[i] == x) then 402 | local _g = i; 403 | local _g1 = self.length - 1; 404 | while (_g < _g1) do 405 | _g = _g + 1; 406 | local j = _g - 1; 407 | self[j] = self[j + 1]; 408 | end; 409 | self[self.length - 1] = nil; 410 | self.length = self.length - 1; 411 | do return true end; 412 | end; 413 | end; 414 | do return false end 415 | end 416 | Array.prototype.contains = function(self,x) 417 | local _g = 0; 418 | local _g1 = self.length; 419 | while (_g < _g1) do 420 | _g = _g + 1; 421 | if (self[_g - 1] == x) then 422 | do return true end; 423 | end; 424 | end; 425 | do return false end 426 | end 427 | Array.prototype.indexOf = function(self,x,fromIndex) 428 | local _end = self.length; 429 | if (fromIndex == nil) then 430 | fromIndex = 0; 431 | else 432 | if (fromIndex < 0) then 433 | fromIndex = self.length + fromIndex; 434 | if (fromIndex < 0) then 435 | fromIndex = 0; 436 | end; 437 | end; 438 | end; 439 | local _g = fromIndex; 440 | while (_g < _end) do 441 | _g = _g + 1; 442 | local i = _g - 1; 443 | if (x == self[i]) then 444 | do return i end; 445 | end; 446 | end; 447 | do return -1 end 448 | end 449 | Array.prototype.lastIndexOf = function(self,x,fromIndex) 450 | if ((fromIndex == nil) or (fromIndex >= self.length)) then 451 | fromIndex = self.length - 1; 452 | else 453 | if (fromIndex < 0) then 454 | fromIndex = self.length + fromIndex; 455 | if (fromIndex < 0) then 456 | do return -1 end; 457 | end; 458 | end; 459 | end; 460 | local i = fromIndex; 461 | while (i >= 0) do 462 | if (self[i] == x) then 463 | do return i end; 464 | else 465 | i = i - 1; 466 | end; 467 | end; 468 | do return -1 end 469 | end 470 | Array.prototype.copy = function(self) 471 | local _g = _hx_tab_array({}, 0); 472 | local _g1 = 0; 473 | while (_g1 < self.length) do 474 | local i = self[_g1]; 475 | _g1 = _g1 + 1; 476 | _g:push(i); 477 | end; 478 | do return _g end 479 | end 480 | Array.prototype.map = function(self,f) 481 | local _g = _hx_tab_array({}, 0); 482 | local _g1 = 0; 483 | while (_g1 < self.length) do 484 | local i = self[_g1]; 485 | _g1 = _g1 + 1; 486 | _g:push(f(i)); 487 | end; 488 | do return _g end 489 | end 490 | Array.prototype.filter = function(self,f) 491 | local _g = _hx_tab_array({}, 0); 492 | local _g1 = 0; 493 | while (_g1 < self.length) do 494 | local i = self[_g1]; 495 | _g1 = _g1 + 1; 496 | if (f(i)) then 497 | _g:push(i); 498 | end; 499 | end; 500 | do return _g end 501 | end 502 | Array.prototype.iterator = function(self) 503 | do return __haxe_iterators_ArrayIterator.new(self) end 504 | end 505 | Array.prototype.keyValueIterator = function(self) 506 | do return __haxe_iterators_ArrayKeyValueIterator.new(self) end 507 | end 508 | Array.prototype.resize = function(self,len) 509 | if (self.length < len) then 510 | self.length = len; 511 | else 512 | if (self.length > len) then 513 | local _g = len; 514 | local _g1 = self.length; 515 | while (_g < _g1) do 516 | _g = _g + 1; 517 | self[_g - 1] = nil; 518 | end; 519 | self.length = len; 520 | end; 521 | end; 522 | end 523 | 524 | ___Main_Main_Fields_.new = {} 525 | ___Main_Main_Fields_.main = function() 526 | vim.api.nvim_create_user_command("HaxeCmd", function(args) 527 | vim.pretty_print(args); 528 | vim.pretty_print(vim.spell.check("Hello bru! Hau are you?")[1][1]); 529 | vim.ui.select(({"a"}), ({prompt = "Pick one sexy option"}), function(choice,_) 530 | vim.pretty_print(choice); 531 | end); 532 | end, ({bang = true, complete = Std.string("customlist,v:lua.") .. Std.string("require'packer'.plugin_complete"), desc = "Testing from haxe", force = true, nargs = 1, range = "%"})); 533 | __vim_Vimx.autocmd("HaxeEvent", __vim__VimTypes_LuaArray_Impl_.from(_hx_tab_array({[0]="BufWritePost"}, 1)), "*.hx", "Created from haxe", function() 534 | vim.pretty_print("Hello from axe", vim.fn.expand(_G.string.format("%s%s", "%", ":p"))); 535 | do return true end; 536 | end); 537 | vim.keymap.set("n", "tl", ___Main_Main_Fields_.nexTab, ({desc = "Go to next tab", expr = false, silent = true})); 538 | vim.o.inccommand = "split"; 539 | end 540 | ___Main_Main_Fields_.nexTab = function() 541 | local pages = vim.api.nvim_list_tabpages(); 542 | local currentTab = vim.api.nvim_get_current_tabpage(); 543 | local nextT = __vim__TableTools_TableTools_Fields_.findNext(pages, function(id) 544 | do return id == currentTab end; 545 | end); 546 | vim.api.nvim_set_current_tabpage((function() 547 | local _hx_1 548 | if (nextT == nil) then 549 | _hx_1 = pages[1]; else 550 | _hx_1 = nextT; end 551 | return _hx_1 552 | end )()); 553 | end 554 | 555 | Math.new = {} 556 | Math.isNaN = function(f) 557 | do return f ~= f end; 558 | end 559 | Math.isFinite = function(f) 560 | if (f > -_G.math.huge) then 561 | do return f < _G.math.huge end; 562 | else 563 | do return false end; 564 | end; 565 | end 566 | Math.min = function(a,b) 567 | if (Math.isNaN(a) or Math.isNaN(b)) then 568 | do return (0/0) end; 569 | else 570 | do return _G.math.min(a, b) end; 571 | end; 572 | end 573 | 574 | String.new = function(string) 575 | local self = _hx_new(String.prototype) 576 | String.super(self,string) 577 | self = string 578 | return self 579 | end 580 | String.super = function(self,string) 581 | end 582 | String.__index = function(s,k) 583 | if (k == "length") then 584 | do return _G.string.len(s) end; 585 | else 586 | local o = String.prototype; 587 | local field = k; 588 | if ((function() 589 | local _hx_1 590 | if ((_G.type(o) == "string") and ((String.prototype[field] ~= nil) or (field == "length"))) then 591 | _hx_1 = true; elseif (o.__fields__ ~= nil) then 592 | _hx_1 = o.__fields__[field] ~= nil; else 593 | _hx_1 = o[field] ~= nil; end 594 | return _hx_1 595 | end )()) then 596 | do return String.prototype[k] end; 597 | else 598 | if (String.__oldindex ~= nil) then 599 | if (_G.type(String.__oldindex) == "function") then 600 | do return String.__oldindex(s, k) end; 601 | else 602 | if (_G.type(String.__oldindex) == "table") then 603 | do return String.__oldindex[k] end; 604 | end; 605 | end; 606 | do return nil end; 607 | else 608 | do return nil end; 609 | end; 610 | end; 611 | end; 612 | end 613 | String.indexOfEmpty = function(s,startIndex) 614 | local length = _G.string.len(s); 615 | if (startIndex < 0) then 616 | startIndex = length + startIndex; 617 | if (startIndex < 0) then 618 | startIndex = 0; 619 | end; 620 | end; 621 | if (startIndex > length) then 622 | do return length end; 623 | else 624 | do return startIndex end; 625 | end; 626 | end 627 | String.fromCharCode = function(code) 628 | do return _G.string.char(code) end; 629 | end 630 | String.prototype = _hx_e(); 631 | String.prototype.toUpperCase = function(self) 632 | do return _G.string.upper(self) end 633 | end 634 | String.prototype.toLowerCase = function(self) 635 | do return _G.string.lower(self) end 636 | end 637 | String.prototype.indexOf = function(self,str,startIndex) 638 | if (startIndex == nil) then 639 | startIndex = 1; 640 | else 641 | startIndex = startIndex + 1; 642 | end; 643 | if (str == "") then 644 | do return String.indexOfEmpty(self, startIndex - 1) end; 645 | end; 646 | local r = _G.string.find(self, str, startIndex, true); 647 | if ((r ~= nil) and (r > 0)) then 648 | do return r - 1 end; 649 | else 650 | do return -1 end; 651 | end; 652 | end 653 | String.prototype.lastIndexOf = function(self,str,startIndex) 654 | local ret = -1; 655 | if (startIndex == nil) then 656 | startIndex = #self; 657 | end; 658 | while (true) do 659 | local startIndex1 = ret + 1; 660 | if (startIndex1 == nil) then 661 | startIndex1 = 1; 662 | else 663 | startIndex1 = startIndex1 + 1; 664 | end; 665 | local p; 666 | if (str == "") then 667 | p = String.indexOfEmpty(self, startIndex1 - 1); 668 | else 669 | local r = _G.string.find(self, str, startIndex1, true); 670 | p = (function() 671 | local _hx_1 672 | if ((r ~= nil) and (r > 0)) then 673 | _hx_1 = r - 1; else 674 | _hx_1 = -1; end 675 | return _hx_1 676 | end )(); 677 | end; 678 | if (((p == -1) or (p > startIndex)) or (p == ret)) then 679 | break; 680 | end; 681 | ret = p; 682 | end; 683 | do return ret end 684 | end 685 | String.prototype.split = function(self,delimiter) 686 | local idx = 1; 687 | local ret = _hx_tab_array({}, 0); 688 | while (idx ~= nil) do 689 | local newidx = 0; 690 | if (#delimiter > 0) then 691 | newidx = _G.string.find(self, delimiter, idx, true); 692 | else 693 | if (idx >= #self) then 694 | newidx = nil; 695 | else 696 | newidx = idx + 1; 697 | end; 698 | end; 699 | if (newidx ~= nil) then 700 | ret:push(_G.string.sub(self, idx, newidx - 1)); 701 | idx = newidx + #delimiter; 702 | else 703 | ret:push(_G.string.sub(self, idx, #self)); 704 | idx = nil; 705 | end; 706 | end; 707 | do return ret end 708 | end 709 | String.prototype.toString = function(self) 710 | do return self end 711 | end 712 | String.prototype.substring = function(self,startIndex,endIndex) 713 | if (endIndex == nil) then 714 | endIndex = #self; 715 | end; 716 | if (endIndex < 0) then 717 | endIndex = 0; 718 | end; 719 | if (startIndex < 0) then 720 | startIndex = 0; 721 | end; 722 | if (endIndex < startIndex) then 723 | do return _G.string.sub(self, endIndex + 1, startIndex) end; 724 | else 725 | do return _G.string.sub(self, startIndex + 1, endIndex) end; 726 | end; 727 | end 728 | String.prototype.charAt = function(self,index) 729 | do return _G.string.sub(self, index + 1, index + 1) end 730 | end 731 | String.prototype.charCodeAt = function(self,index) 732 | do return _G.string.byte(self, index + 1) end 733 | end 734 | String.prototype.substr = function(self,pos,len) 735 | if ((len == nil) or (len > (pos + #self))) then 736 | len = #self; 737 | else 738 | if (len < 0) then 739 | len = #self + len; 740 | end; 741 | end; 742 | if (pos < 0) then 743 | pos = #self + pos; 744 | end; 745 | if (pos < 0) then 746 | pos = 0; 747 | end; 748 | do return _G.string.sub(self, pos + 1, pos + len) end 749 | end 750 | 751 | Std.new = {} 752 | Std.string = function(s) 753 | do return _hx_tostring(s, 0) end; 754 | end 755 | Std.int = function(x) 756 | if (not Math.isFinite(x) or Math.isNaN(x)) then 757 | do return 0 end; 758 | else 759 | do return _hx_bit_clamp(x) end; 760 | end; 761 | end 762 | 763 | __haxe_iterators_ArrayIterator.new = function(array) 764 | local self = _hx_new(__haxe_iterators_ArrayIterator.prototype) 765 | __haxe_iterators_ArrayIterator.super(self,array) 766 | return self 767 | end 768 | __haxe_iterators_ArrayIterator.super = function(self,array) 769 | self.current = 0; 770 | self.array = array; 771 | end 772 | __haxe_iterators_ArrayIterator.prototype = _hx_e(); 773 | __haxe_iterators_ArrayIterator.prototype.hasNext = function(self) 774 | do return self.current < self.array.length end 775 | end 776 | __haxe_iterators_ArrayIterator.prototype.next = function(self) 777 | do return self.array[(function() 778 | local _hx_obj = self; 779 | local _hx_fld = 'current'; 780 | local _ = _hx_obj[_hx_fld]; 781 | _hx_obj[_hx_fld] = _hx_obj[_hx_fld] + 1; 782 | return _; 783 | end)()] end 784 | end 785 | 786 | __haxe_iterators_ArrayKeyValueIterator.new = function(array) 787 | local self = _hx_new() 788 | __haxe_iterators_ArrayKeyValueIterator.super(self,array) 789 | return self 790 | end 791 | __haxe_iterators_ArrayKeyValueIterator.super = function(self,array) 792 | self.array = array; 793 | end 794 | 795 | __lua_StringMap.new = function() 796 | local self = _hx_new(__lua_StringMap.prototype) 797 | __lua_StringMap.super(self) 798 | return self 799 | end 800 | __lua_StringMap.super = function(self) 801 | self.h = ({}); 802 | end 803 | __lua_StringMap.prototype = _hx_e(); 804 | __lua_StringMap.prototype.set = function(self,key,value) 805 | if (value == nil) then 806 | self.h[key] = __lua_StringMap.tnull; 807 | else 808 | self.h[key] = value; 809 | end; 810 | end 811 | __lua_StringMap.prototype.get = function(self,key) 812 | local ret = self.h[key]; 813 | if (ret == __lua_StringMap.tnull) then 814 | do return nil end; 815 | end; 816 | do return ret end 817 | end 818 | 819 | __vim__TableTools_TableTools_Fields_.new = {} 820 | __vim__TableTools_TableTools_Fields_.findNext = function(table,fn) 821 | local _hx_1_p_next, _hx_1_p_table, _hx_1_p_index = _G.ipairs(table); 822 | local next = _hx_1_p_next; 823 | local t = _hx_1_p_table; 824 | local loop = nil; 825 | loop = function(next,table,nextP) 826 | local _hx_continue_1 = false; 827 | while (true) do repeat 828 | if (fn(nextP.value)) then 829 | do return _G.select(2, next(table, nextP.index)) end; 830 | else 831 | nextP = _hx_box_mr(_hx_table.pack(next(table, nextP.index)), {"index", "value"}); 832 | break; 833 | end;until true 834 | if _hx_continue_1 then 835 | _hx_continue_1 = false; 836 | break; 837 | end; 838 | 839 | end; 840 | end; 841 | do return loop(next, t, _hx_box_mr(_hx_table.pack(next(t, _hx_1_p_index)), {"index", "value"})) end; 842 | end 843 | 844 | __vim__VimTypes_LuaArray_Impl_.new = {} 845 | __vim__VimTypes_LuaArray_Impl_.from = function(arr) 846 | local ret = ({}); 847 | local _g = 0; 848 | local _g1 = arr.length; 849 | while (_g < _g1) do 850 | _g = _g + 1; 851 | local idx = _g - 1; 852 | ret[idx + 1] = arr[idx]; 853 | end; 854 | do return ret end; 855 | end 856 | 857 | __vim_Vimx.new = {} 858 | _hx_exports["vimx"] = __vim_Vimx 859 | __vim_Vimx.autocmd = function(groupName,events,pattern,description,cb) 860 | local group; 861 | local _g = __vim_Vimx.autogroups:get(groupName); 862 | if (_g == nil) then 863 | group = vim.api.nvim_create_augroup(groupName, ({clear = true})); 864 | __vim_Vimx.autogroups:set(groupName, group); 865 | else 866 | group = _g; 867 | end; 868 | vim.api.nvim_create_autocmd(events, ({pattern = pattern, callback = cb, group = group, desc = (function() 869 | local _hx_1 870 | if (description == nil) then 871 | _hx_1 = Std.string(Std.string(Std.string(Std.string("") .. Std.string(groupName)) .. Std.string(":[")) .. Std.string(pattern)) .. Std.string("]"); else 872 | _hx_1 = description; end 873 | return _hx_1 874 | end )(), once = false, nested = false})); 875 | end 876 | __vim_Vimx.copyToClipboard = function(str) 877 | vim.cmd(Std.string(Std.string("let @* = \"") .. Std.string(str)) .. Std.string("\"")); 878 | vim.notify("Copied to clipboard", "info"); 879 | end 880 | __vim_Vimx.linesInCurrentWindow = function() 881 | do return vim.fn.line("$", 0) end; 882 | end 883 | __vim_Vimx.firstLineVisibleCurrentWindow = function() 884 | do return vim.fn.line("w0", 0) end; 885 | end 886 | __vim_Vimx.lastLineVisibleCurrentWindow = function() 887 | do return vim.fn.line("w$", 0) end; 888 | end 889 | if _hx_bit_raw then 890 | _hx_bit_clamp = function(v) 891 | if v <= 2147483647 and v >= -2147483648 then 892 | if v > 0 then return _G.math.floor(v) 893 | else return _G.math.ceil(v) 894 | end 895 | end 896 | if v > 2251798999999999 then v = v*2 end; 897 | if (v ~= v or math.abs(v) == _G.math.huge) then return nil end 898 | return _hx_bit_raw.band(v, 2147483647 ) - math.abs(_hx_bit_raw.band(v, 2147483648)) 899 | end 900 | else 901 | _hx_bit_clamp = function(v) 902 | if v < -2147483648 then 903 | return -2147483648 904 | elseif v > 2147483647 then 905 | return 2147483647 906 | elseif v > 0 then 907 | return _G.math.floor(v) 908 | else 909 | return _G.math.ceil(v) 910 | end 911 | end 912 | end; 913 | 914 | 915 | 916 | _hx_array_mt.__index = Array.prototype 917 | 918 | local _hx_static_init = function() 919 | __lua_StringMap.tnull = ({}); 920 | 921 | __vim_Vimx.autogroups = __lua_StringMap.new(); 922 | 923 | 924 | end 925 | 926 | _hx_box_mr = function(x,nt) 927 | res = _hx_o({__fields__={}}) 928 | for i,v in ipairs(nt) do 929 | res[v] = x[i] 930 | end 931 | return res 932 | end 933 | 934 | _hx_table = {} 935 | _hx_table.pack = _G.table.pack or function(...) 936 | return {...} 937 | end 938 | _hx_table.unpack = _G.table.unpack or _G.unpack 939 | _hx_table.maxn = _G.table.maxn or function(t) 940 | local maxn=0; 941 | for i in pairs(t) do 942 | maxn=type(i)=='number'and i>maxn and i or maxn 943 | end 944 | return maxn 945 | end; 946 | 947 | _hx_static_init(); 948 | _G.xpcall(___Main_Main_Fields_.main, _hx_error) 949 | return _hx_exports 950 | -------------------------------------------------------------------------------- /src/Main.hx: -------------------------------------------------------------------------------- 1 | import vim.Vim; 2 | import vim.Vimx; 3 | import vim.VimTypes; 4 | import lua.Table.create as t; 5 | 6 | function main() { 7 | // Example of a command that supports auto-completion and takes arguments 8 | vim.Api.create_user_command_completion("HaxeCmd", (args) -> { 9 | Vim.print(args); 10 | final spellRes = Spell.check("Hello bru! Hau are you?"); 11 | Vim.print(spellRes[1].first()); 12 | vim.Ui.select(t(["a"]), {prompt: "Pick one sexy option"}, (choice, _) -> Vim.print(choice)); 13 | }, CustomLua("require'packer'.plugin_complete"), { 14 | desc: "Testing from haxe", 15 | force: true, 16 | bang: true, 17 | range: WholeFile, 18 | }); 19 | // Example of an autocmd that is triggered when a file is saved with the extension .hx only once 20 | // This uses the higher level Vimx API 21 | Vimx.autocmd('HaxeEvent', [BufWritePost], "*.hx", "Created from haxe", () -> { 22 | var filename = Vim.expand(ExpandString.plus(CurentFile, FullPath)); 23 | Vim.print('Hello from axe', filename); 24 | return true; 25 | }); 26 | // One example keymap that actually does something useful 27 | vim.Keymap.set(Normal, "tl", nexTab, {desc: "Go to next tab", silent: true, expr: false}); 28 | // Example showing how to configure vim options. This one shows the effects of a search / replace in a live preview window 29 | Vim.o.inccommand = "split"; 30 | } 31 | 32 | // Example of a function that uses some of the provided Vim specific helpers 33 | // to write succinct code that is also type safe 34 | 35 | /** 36 | Goes to the next tab, cycling to the first on the edges 37 | */ 38 | function nexTab() { 39 | final pages = vim.Api.nvim_list_tabpages(); 40 | final currentTab = vim.Api.nvim_get_current_tabpage(); 41 | final nextT = pages.findNext(id -> id == currentTab); 42 | vim.Api.nvim_set_current_tabpage(nextT.or(pages[1])); 43 | } 44 | -------------------------------------------------------------------------------- /src/import.hx: -------------------------------------------------------------------------------- 1 | using Lambda; 2 | using Safety; 3 | using vim.TableTools; 4 | --------------------------------------------------------------------------------