style(core): run stylua

This commit is contained in:
Ade Attwood 2023-11-24 08:01:34 +00:00
parent 0fa7e58c98
commit da223e930d
8 changed files with 193 additions and 188 deletions

View file

@ -1,6 +1,5 @@
require "modules.clojure"
require("modules.clojure") require "modules.lua-lsp"
require("modules.lua-lsp") require "modules.nvim"
require("modules.nvim") require "modules.nvm"
require("modules.nvm") require "modules.tmux"
require("modules.tmux")

View file

@ -14,7 +14,7 @@
-- locations the duplication exists. -- locations the duplication exists.
-- --
local codeclimate_namespace = vim.api.nvim_create_namespace("codeclimate") local codeclimate_namespace = vim.api.nvim_create_namespace "codeclimate"
local codeclimate_auto_command_group = vim.api.nvim_create_augroup("codeclimate", { clear = true }) local codeclimate_auto_command_group = vim.api.nvim_create_augroup("codeclimate", { clear = true })
-- Get the relative path of a `buffer` to the vim current working directory -- Get the relative path of a `buffer` to the vim current working directory
@ -31,7 +31,7 @@ local function read_line(file_path, line_number)
return "" return ""
end end
local index = 0; local index = 0
while index < line_number do while index < line_number do
file:read() file:read()
index = index + 1 index = index + 1
@ -46,8 +46,10 @@ end
-- Populates the vim diagnostics with the codeclimate issues from '/tmp/cc.json' -- Populates the vim diagnostics with the codeclimate issues from '/tmp/cc.json'
local function codeclimate_add_diagnostics() local function codeclimate_add_diagnostics()
local file = io.open("/tmp/cc.json", "rb") local file = io.open("/tmp/cc.json", "rb")
if not file then return nil end if not file then
local issues = vim.json.decode(file:read("*a")) return nil
end
local issues = vim.json.decode(file:read "*a")
local buffer = vim.api.nvim_win_get_buf(0) local buffer = vim.api.nvim_win_get_buf(0)
local buffer_name = get_relative_path(buffer) local buffer_name = get_relative_path(buffer)
@ -55,9 +57,8 @@ local function codeclimate_add_diagnostics()
for index = 1, #issues do for index = 1, #issues do
if issues[index]["location"] ~= nil and issues[index]["location"]["path"] == buffer_name then if issues[index]["location"] ~= nil and issues[index]["location"]["path"] == buffer_name then
local start_line = 0
local start_line = 0; local end_line = 0
local end_line = 0;
if issues[index]["location"]["lines"] ~= nil then if issues[index]["location"]["lines"] ~= nil then
start_line = issues[index]["location"]["lines"]["begin"] - 1 start_line = issues[index]["location"]["lines"]["begin"] - 1
@ -86,8 +87,8 @@ local function codeclimate_add_diagnostics()
message = issues[index]["description"], message = issues[index]["description"],
severity = vim.diagnostic.severity.ERROR, severity = vim.diagnostic.severity.ERROR,
user_data = { user_data = {
other_locations = issues[index]["other_locations"] other_locations = issues[index]["other_locations"],
} },
}) })
::continue:: ::continue::

View file

@ -1,2 +1 @@
require("Comment").setup()
require('Comment').setup()

View file

@ -1,14 +1,13 @@
local cmp = require'cmp' local cmp = require "cmp"
local luasnip = require'luasnip' local luasnip = require "luasnip"
require("copilot").setup({ require("copilot").setup {
suggestion = { enabled = false }, suggestion = { enabled = false },
panel = { enabled = false }, panel = { enabled = false },
}) }
require("copilot_cmp").setup() require("copilot_cmp").setup()
local icons = { local icons = {
Text = "", Text = "",
Method = "", Method = "",
@ -36,15 +35,19 @@ Text = "",
Operator = "", Operator = "",
} }
cmp.setup({ cmp.setup {
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert {
['<C-j>'] = cmp.get_config().mapping['<Down>'], ["<C-j>"] = cmp.get_config().mapping["<Down>"],
['<C-k>'] = cmp.get_config().mapping['<Up>'], ["<C-k>"] = cmp.get_config().mapping["<Up>"],
['<C-l>'] = function() luasnip.jump(1) end, ["<C-l>"] = function()
['<C-h>'] = function() luasnip.jump(-1) end, luasnip.jump(1)
end,
["<C-h>"] = function()
luasnip.jump(-1)
end,
['<C-e>'] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), ["<CR>"] = cmp.mapping.confirm { select = true },
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
@ -60,13 +63,13 @@ cmp.setup({
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
}), },
sources = { sources = {
{ name = "luasnip" }, { name = "luasnip" },
{ name = "copilot" }, { name = "copilot" },
{ name = 'nvim_lsp' }, { name = "nvim_lsp" },
{ name = 'buffer' }, { name = "buffer" },
{ name = 'path' }, { name = "path" },
}, },
snippet = { snippet = {
expand = function(args) expand = function(args)
@ -78,7 +81,7 @@ cmp.setup({
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
formatting = { formatting = {
fields = { 'menu', 'abbr', 'kind' }, fields = { "menu", "abbr", "kind" },
format = function(entry, vim_item) format = function(entry, vim_item)
-- Give the completion menu a consistent size to stop it jumping arround -- Give the completion menu a consistent size to stop it jumping arround
local width = 40 local width = 40
@ -96,7 +99,7 @@ cmp.setup({
experimental = { experimental = {
ghost_text = true, ghost_text = true,
}, },
}) }
cmp.setup.cmdline(":", { cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),

View file

@ -1,4 +1,4 @@
local lint = require('lint') local lint = require "lint"
local severities = { local severities = {
error = vim.diagnostic.severity.ERROR, error = vim.diagnostic.severity.ERROR,
@ -6,15 +6,15 @@ local severities = {
} }
lint.linters.psalm = { lint.linters.psalm = {
cmd = 'psalm', cmd = "psalm",
stdin = false, stdin = false,
args = { args = {
'--output-format=json', "--output-format=json",
'--show-info=true' "--show-info=true",
}, },
-- ignore_exitcode = true, -- ignore_exitcode = true,
parser = function(output, _) parser = function(output, _)
if vim.trim(output) == '' then if vim.trim(output) == "" then
return {} return {}
end end
@ -28,13 +28,13 @@ lint.linters.psalm = {
col = err.column_from - 1, col = err.column_from - 1,
end_col = err.column_to - 1, end_col = err.column_to - 1,
message = err.message, message = err.message,
source = 'psalm', source = "psalm",
severity = assert(severities[err.severity], 'missing mapping for severity ' .. err.severity), severity = assert(severities[err.severity], "missing mapping for severity " .. err.severity),
}) })
end end
return diagnostics return diagnostics
end end,
} }
local get_language_id = function() local get_language_id = function()
@ -43,52 +43,52 @@ local get_language_id = function()
end end
lint.linters.cspell = { lint.linters.cspell = {
cmd = 'cspell', cmd = "cspell",
stdin = true, stdin = true,
ignore_exitcode = true, ignore_exitcode = true,
args = { args = {
'lint', "lint",
'--no-color', "--no-color",
'--no-progress', "--no-progress",
'--no-summary', "--no-summary",
"--config=" .. os.getenv("HOME") .. "/.cspell.json", "--config=" .. os.getenv "HOME" .. "/.cspell.json",
get_language_id, get_language_id,
'--', "--",
'stdin' "stdin",
}, },
stream = 'stdout', stream = "stdout",
parser = require('lint.parser').from_errorformat('%f:%l:%c - %m', { parser = require("lint.parser").from_errorformat("%f:%l:%c - %m", {
source = 'cspell', source = "cspell",
severity = vim.diagnostic.severity.INFO severity = vim.diagnostic.severity.INFO,
}) }),
} }
lint.linters_by_ft = {}; lint.linters_by_ft = {}
if vim.fn.executable('phpcs') == 1 then if vim.fn.executable "phpcs" == 1 then
lint.linters_by_ft.php = { "phpcs" } lint.linters_by_ft.php = { "phpcs" }
end end
if vim.fn.executable('eslint_d') == 1 then if vim.fn.executable "eslint_d" == 1 then
lint.linters_by_ft.typescript = { "eslint_d" } lint.linters_by_ft.typescript = { "eslint_d" }
lint.linters_by_ft.javascript = { "eslint_d" } lint.linters_by_ft.javascript = { "eslint_d" }
lint.linters_by_ft.typescriptreact = { "eslint_d" } lint.linters_by_ft.typescriptreact = { "eslint_d" }
lint.linters_by_ft.javascriptreact = { "eslint_d" } lint.linters_by_ft.javascriptreact = { "eslint_d" }
end end
if vim.fn.executable('luacheck') == 1 then if vim.fn.executable "luacheck" == 1 then
lint.linters_by_ft.lua = { "luacheck" } lint.linters_by_ft.lua = { "luacheck" }
end end
if vim.fn.executable('stylelint') == 1 then if vim.fn.executable "stylelint" == 1 then
lint.linters_by_ft.scss = { "stylelint" } lint.linters_by_ft.scss = { "stylelint" }
end end
if vim.fn.executable('rubocop') == 1 then if vim.fn.executable "rubocop" == 1 then
lint.linters_by_ft.ruby = { "rubocop" } lint.linters_by_ft.ruby = { "rubocop" }
end end
if vim.fn.executable('erb_lint') == 1 then if vim.fn.executable "erb_lint" == 1 then
lint.linters_by_ft.eruby = { "erb_lint" } lint.linters_by_ft.eruby = { "erb_lint" }
end end
@ -112,10 +112,9 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost" }, {
-- Only try and run spell checking on buffers that have a filetype. This is -- Only try and run spell checking on buffers that have a filetype. This is
-- mainly to disable spell checking in vim lsp popup buffers. -- mainly to disable spell checking in vim lsp popup buffers.
if should_lint then if should_lint then
table.insert(linters, 'cspell') table.insert(linters, "cspell")
end end
lint.try_lint(linters) lint.try_lint(linters)
end, end,
}) })

View file

@ -1,7 +1,7 @@
local lspconfig = require "lspconfig" local lspconfig = require "lspconfig"
local workspace_library = vim.api.nvim_get_runtime_file("lua", true) local workspace_library = vim.api.nvim_get_runtime_file("lua", true)
table.insert(workspace_library, os.getenv("HOME") .. "/Code/src/github.com/AdeAttwood/Configz/definitions/configz.lua") table.insert(workspace_library, os.getenv "HOME" .. "/Code/src/github.com/AdeAttwood/Configz/definitions/configz.lua")
local servers = { local servers = {
-- Language servers for the day to day web development, could probably think -- Language servers for the day to day web development, could probably think
@ -76,7 +76,6 @@ local on_attach = function(_, bufnr)
group = "lsp_document_highlight", group = "lsp_document_highlight",
desc = "Clear All the References", desc = "Clear All the References",
}) })
end end
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
@ -99,20 +98,20 @@ vim.fn.sign_define(
{ text = "", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" } { text = "", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }
) )
local border = 'rounded' local border = "rounded"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.lsp.handlers["textDocument/show_line_diagnostics"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) vim.lsp.handlers["textDocument/show_line_diagnostics"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.lsp.handlers["textDocument/diagnostic"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) vim.lsp.handlers["textDocument/diagnostic"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.lsp.handlers["textDocument/diagnostics"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) vim.lsp.handlers["textDocument/diagnostics"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.diagnostic.config({ vim.diagnostic.config {
float = { float = {
focusable = false, focusable = false,
border = border border = border,
},
} }
})
vim.cmd([[set updatetime=1000]]) vim.cmd [[set updatetime=1000]]
vim.api.nvim_create_augroup("diagnostic_float", { clear = true }) vim.api.nvim_create_augroup("diagnostic_float", { clear = true })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
callback = function() callback = function()

View file

@ -23,4 +23,3 @@ vim.api.nvim_create_user_command("PrrGoToLine", function()
vim.cmd("e " .. target_file) vim.cmd("e " .. target_file)
vim.fn.cursor(target_line - 1, column) vim.fn.cursor(target_line - 1, column)
end, { bang = true, desc = "Open the current file at the poin in a prr buffer" }) end, { bang = true, desc = "Open the current file at the poin in a prr buffer" })

View file

@ -1,4 +1,4 @@
require'nvim-treesitter.configs'.setup { require("nvim-treesitter.configs").setup {
playground = { enable = true }, playground = { enable = true },
indent = { enable = false }, indent = { enable = false },
rainbow = { enable = true }, rainbow = { enable = true },
@ -8,6 +8,12 @@ require'nvim-treesitter.configs'.setup {
additional_vim_regex_highlighting = true, additional_vim_regex_highlighting = true,
}, },
ensure_installed = { ensure_installed = {
"typescript", "javascript", "tsx", "php", "html", "go", "clojure" "typescript",
"javascript",
"tsx",
"php",
"html",
"go",
"clojure",
}, },
} }