feat: initial commit

This commit is contained in:
Folke Lemaitre
2024-05-20 23:02:42 +02:00
commit 3783df5705
4 changed files with 125 additions and 0 deletions

69
lua/ts-comments.lua Normal file
View File

@@ -0,0 +1,69 @@
local M = {}
local defaults = {
---@type table<string, string|table<string,string>>
lang = {
astro = "<!-- %s -->",
c = "// %s",
cpp = "// %s",
css = "/* %s */",
gleam = "// %s",
glimmer = "{{! %s }}",
graphql = "# %s",
handlebars = "{{! %s }}",
hcl = "# %s",
html = "<!-- %s -->",
ini = "; %s",
php = "// %s",
rego = "# %s",
rescript = "// %s",
sql = "-- %s",
svelte = "<!-- %s -->",
terraform = "# %s",
tsx = {
_ = "// %s",
call_expression = "// %s",
comment = "// %s",
jsx_attribute = "// %s",
jsx_element = "{/* %s */}",
jsx_fragment = "{/* %s */}",
spread_element = "// %s",
statement_block = "// %s",
},
twig = "{# %s #}",
typescript = "// %s",
vim = '" %s',
vue = "<!-- %s -->",
},
}
defaults.lang.javascript = vim.deepcopy(defaults.lang.tsx)
function M.setup(opts)
opts = vim.tbl_deep_extend("force", defaults, opts or {})
local get_option = vim.filetype.get_option
vim.filetype.get_option = function(filetype, option)
if option ~= "commentstring" then
return get_option(filetype, option)
end
local lang = vim.treesitter.language.get_lang(filetype)
local ret = opts.lang[lang]
if type(ret) == "table" then
local node = vim.treesitter.get_node({ ignore_injections = false })
while node do
if ret[node:type()] then
ret = ret[node:type()]
break
end
node = node:parent()
end
if type(ret) == "table" then
ret = ret._
end
end
return ret or get_option(filetype, option)
end
end
return M

1
selene.toml Normal file
View File

@@ -0,0 +1 @@
std="vim"

6
stylua.toml Normal file
View File

@@ -0,0 +1,6 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120
[sort_requires]
enabled = true

49
vim.toml Normal file
View File

@@ -0,0 +1,49 @@
[selene]
base = "lua51"
name = "vim"
[vim]
any = true
[jit]
any = true
[[describe.args]]
type = "string"
[[describe.args]]
type = "function"
[[it.args]]
type = "string"
[[it.args]]
type = "function"
[[before_each.args]]
type = "function"
[[after_each.args]]
type = "function"
[assert.is_not]
any = true
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
required = false
[[assert.same.args]]
type = "any"
[[assert.same.args]]
type = "any"
[[assert.truthy.args]]
type = "any"
[[assert.spy.args]]
type = "any"
[[assert.stub.args]]
type = "any"