chore(fmt): Finally let's use stylua

Hoping it's as good as go-fmt
This commit is contained in:
hedy
2023-11-17 09:28:33 +08:00
parent d400d4f025
commit dc55a8b942
22 changed files with 247 additions and 307 deletions

View File

@@ -2,9 +2,8 @@ local M = {
name = 'coc',
}
function M.should_use_provider(_)
local not_coc_installed = vim.fn.exists '*CocActionAsync' == 0
local not_coc_installed = vim.fn.exists('*CocActionAsync') == 0
local not_coc_service_initialized = vim.g.coc_service_initialized == 0
if not_coc_installed or not_coc_service_initialized then
@@ -28,61 +27,61 @@ end
---@param result table
local function convert_symbols(result)
local s = {}
local kinds_index = {}
-- create a inverse indexing of symbols.kind
local symbols = require("outline.symbols")
for k, v in pairs(symbols.kinds) do
kinds_index[v] = k
local s = {}
local kinds_index = {}
-- create a inverse indexing of symbols.kind
local symbols = require('outline.symbols')
for k, v in pairs(symbols.kinds) do
kinds_index[v] = k
end
-- rebuild coc.nvim symbol list hierarchy according to the 'level' key
for _, value in pairs(result) do
value.children = {}
value.kind = kinds_index[value.kind]
if #s == 0 then
table.insert(s, value)
goto continue
end
-- rebuild coc.nvim symbol list hierarchy according to the 'level' key
for _, value in pairs(result) do
value.children = {}
value.kind = kinds_index[value.kind]
if #s == 0 then
table.insert(s, value)
goto continue
end
if value.level == s[#s].level then
if value.level == 0 then
table.insert(s, value)
goto continue
end
local tmp = s[#s]
table.remove(s)
table.insert(s[#s].children, tmp)
table.insert(s, value)
elseif value.level == s[#s].level + 1 then
table.insert(s[#s].children, value)
elseif value.level == s[#s].level + 2 then
local tmp = s[#s].children[#(s[#s].children)]
table.remove(s[#s].children)
table.insert(s, tmp)
table.insert(s[#s].children, value)
elseif value.level < s[#s].level then
while value.level < s[#s].level do
local tmp = s[#s]
table.remove(s)
table.insert(s[#s].children, tmp)
end
if s[#s].level ~= 0 then
local tmp = s[#s]
table.remove(s)
table.insert(s[#s].children, tmp)
table.insert(s, value)
else
table.insert(s, value)
end
end
::continue::
end
local top = s[#s]
while top.level ~= 0 do
if value.level == s[#s].level then
if value.level == 0 then
table.insert(s, value)
goto continue
end
local tmp = s[#s]
table.remove(s)
table.insert(s[#s].children, tmp)
table.insert(s, value)
elseif value.level == s[#s].level + 1 then
table.insert(s[#s].children, value)
elseif value.level == s[#s].level + 2 then
local tmp = s[#s].children[#s[#s].children]
table.remove(s[#s].children)
table.insert(s, tmp)
table.insert(s[#s].children, value)
elseif value.level < s[#s].level then
while value.level < s[#s].level do
local tmp = s[#s]
table.remove(s)
table.insert(s[#s].children, top)
top = s[#s]
table.insert(s[#s].children, tmp)
end
if s[#s].level ~= 0 then
local tmp = s[#s]
table.remove(s)
table.insert(s[#s].children, tmp)
table.insert(s, value)
else
table.insert(s, value)
end
end
return s
::continue::
end
local top = s[#s]
while top.level ~= 0 do
table.remove(s)
table.insert(s[#s].children, top)
top = s[#s]
end
return s
end
---@param on_symbols function

View File

@@ -1,14 +1,15 @@
local cfg = require "outline.config"
local cfg = require('outline.config')
local M = {}
local import_prefix = "outline/providers/"
local import_prefix = 'outline/providers/'
_G._outline_current_provider = nil
function M.find_provider()
if not M.providers then
M.providers = vim.tbl_map(function(p) return import_prefix..p end, cfg.get_providers())
M.providers = vim.tbl_map(function(p)
return import_prefix .. p
end, cfg.get_providers())
end
for _, name in ipairs(M.providers) do
local provider = require(name)

View File

@@ -1,6 +1,6 @@
local config = require 'outline.config'
local lsp_utils = require 'outline.utils.lsp_utils'
local jsx = require 'outline.utils.jsx'
local config = require('outline.config')
local jsx = require('outline.utils.jsx')
local lsp_utils = require('outline.utils.lsp_utils')
local M = {
name = 'lsp',
@@ -10,9 +10,9 @@ local M = {
function M.get_status()
if not M.client then
return "No clients"
return 'No clients'
end
return "client: "..M.client.name
return 'client: ' .. M.client.name
end
local function get_params()
@@ -83,15 +83,10 @@ end
---@param on_symbols function
function M.request_symbols(on_symbols, opts)
vim.lsp.buf_request_all(
0,
'textDocument/documentSymbol',
get_params(),
function (response)
response = M.postprocess_symbols(response)
on_symbols(response, opts)
end
)
vim.lsp.buf_request_all(0, 'textDocument/documentSymbol', get_params(), function(response)
response = M.postprocess_symbols(response)
on_symbols(response, opts)
end)
end
return M