chore: use stylua for formatting (#1040)

* chore: stylua job and config

* reformat with stylua
This commit is contained in:
Simon Hauser
2021-07-23 17:42:37 +02:00
committed by GitHub
parent 664690029f
commit 79644ab677
75 changed files with 3201 additions and 2809 deletions

View File

@@ -1,10 +1,10 @@
local context_manager = require('plenary.context_manager')
local context_manager = require "plenary.context_manager"
local has_ts, _ = pcall(require, 'nvim-treesitter')
local _, ts_configs = pcall(require, 'nvim-treesitter.configs')
local _, ts_parsers = pcall(require, 'nvim-treesitter.parsers')
local has_ts, _ = pcall(require, "nvim-treesitter")
local _, ts_configs = pcall(require, "nvim-treesitter.configs")
local _, ts_parsers = pcall(require, "nvim-treesitter.parsers")
local Job = require('plenary.job')
local Job = require "plenary.job"
local utils = {}
@@ -30,33 +30,41 @@ utils.job_maker = function(cmd, bufnr, opts)
-- if any of them are missing, cache will be skipped
if opts.bufname ~= opts.value or not opts.bufname or not opts.value then
local command = table.remove(cmd, 1)
Job:new({
command = command,
args = cmd,
env = opts.env,
cwd = opts.cwd,
on_exit = vim.schedule_wrap(function(j)
if not vim.api.nvim_buf_is_valid(bufnr) then return end
if opts.mode == "append" then
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, j:result())
elseif opts.mode == "insert" then
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, j:result())
end
if opts.callback then opts.callback(bufnr, j:result()) end
end)
}):start()
Job
:new({
command = command,
args = cmd,
env = opts.env,
cwd = opts.cwd,
on_exit = vim.schedule_wrap(function(j)
if not vim.api.nvim_buf_is_valid(bufnr) then
return
end
if opts.mode == "append" then
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, j:result())
elseif opts.mode == "insert" then
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, j:result())
end
if opts.callback then
opts.callback(bufnr, j:result())
end
end),
})
:start()
else
if opts.callback then opts.callback(bufnr) end
if opts.callback then
opts.callback(bufnr)
end
end
end
local function has_filetype(ft)
return ft and ft ~= ''
return ft and ft ~= ""
end
--- Attach default highlighter which will choose between regex and ts
utils.highlighter = function(bufnr, ft)
if not(utils.ts_highlighter(bufnr, ft)) then
if not (utils.ts_highlighter(bufnr, ft)) then
utils.regex_highlighter(bufnr, ft)
end
end
@@ -82,8 +90,10 @@ local treesitter_attach = function(bufnr, ft)
end
vim.treesitter.highlighter.new(ts_parsers.get_parser(bufnr, lang))
local is_table = type(config.additional_vim_regex_highlighting) == "table"
if config.additional_vim_regex_highlighting and
(not is_table or vim.tbl_contains(config.additional_vim_regex_highlighting, lang)) then
if
config.additional_vim_regex_highlighting
and (not is_table or vim.tbl_contains(config.additional_vim_regex_highlighting, lang))
then
vim.api.nvim_buf_set_option(bufnr, "syntax", ft)
end
return true
@@ -94,10 +104,10 @@ end
-- Attach ts highlighter
utils.ts_highlighter = function(bufnr, ft)
if not has_ts then
has_ts, _ = pcall(require, 'nvim-treesitter')
has_ts, _ = pcall(require, "nvim-treesitter")
if has_ts then
_, ts_configs = pcall(require, 'nvim-treesitter.configs')
_, ts_parsers = pcall(require, 'nvim-treesitter.parsers')
_, ts_configs = pcall(require, "nvim-treesitter.configs")
_, ts_parsers = pcall(require, "nvim-treesitter.parsers")
end
end