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.lua-lsp")
require("modules.nvim")
require("modules.nvm")
require("modules.tmux")
require "modules.clojure"
require "modules.lua-lsp"
require "modules.nvim"
require "modules.nvm"
require "modules.tmux"

View file

@ -14,7 +14,7 @@
-- 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 })
-- 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 ""
end
local index = 0;
local index = 0
while index < line_number do
file:read()
index = index + 1
@ -46,8 +46,10 @@ end
-- Populates the vim diagnostics with the codeclimate issues from '/tmp/cc.json'
local function codeclimate_add_diagnostics()
local file = io.open("/tmp/cc.json", "rb")
if not file then return nil end
local issues = vim.json.decode(file:read("*a"))
if not file then
return nil
end
local issues = vim.json.decode(file:read "*a")
local buffer = vim.api.nvim_win_get_buf(0)
local buffer_name = get_relative_path(buffer)
@ -55,9 +57,8 @@ local function codeclimate_add_diagnostics()
for index = 1, #issues do
if issues[index]["location"] ~= nil and issues[index]["location"]["path"] == buffer_name then
local start_line = 0;
local end_line = 0;
local start_line = 0
local end_line = 0
if issues[index]["location"]["lines"] ~= nil then
start_line = issues[index]["location"]["lines"]["begin"] - 1
@ -86,8 +87,8 @@ local function codeclimate_add_diagnostics()
message = issues[index]["description"],
severity = vim.diagnostic.severity.ERROR,
user_data = {
other_locations = issues[index]["other_locations"]
}
other_locations = issues[index]["other_locations"],
},
})
::continue::

View file

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

View file

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

View file

@ -1,4 +1,4 @@
local lint = require('lint')
local lint = require "lint"
local severities = {
error = vim.diagnostic.severity.ERROR,
@ -6,15 +6,15 @@ local severities = {
}
lint.linters.psalm = {
cmd = 'psalm',
cmd = "psalm",
stdin = false,
args = {
'--output-format=json',
'--show-info=true'
"--output-format=json",
"--show-info=true",
},
-- ignore_exitcode = true,
parser = function(output, _)
if vim.trim(output) == '' then
if vim.trim(output) == "" then
return {}
end
@ -28,13 +28,13 @@ lint.linters.psalm = {
col = err.column_from - 1,
end_col = err.column_to - 1,
message = err.message,
source = 'psalm',
severity = assert(severities[err.severity], 'missing mapping for severity ' .. err.severity),
source = "psalm",
severity = assert(severities[err.severity], "missing mapping for severity " .. err.severity),
})
end
return diagnostics
end
end,
}
local get_language_id = function()
@ -43,52 +43,52 @@ local get_language_id = function()
end
lint.linters.cspell = {
cmd = 'cspell',
cmd = "cspell",
stdin = true,
ignore_exitcode = true,
args = {
'lint',
'--no-color',
'--no-progress',
'--no-summary',
"--config=" .. os.getenv("HOME") .. "/.cspell.json",
"lint",
"--no-color",
"--no-progress",
"--no-summary",
"--config=" .. os.getenv "HOME" .. "/.cspell.json",
get_language_id,
'--',
'stdin'
"--",
"stdin",
},
stream = 'stdout',
parser = require('lint.parser').from_errorformat('%f:%l:%c - %m', {
source = 'cspell',
severity = vim.diagnostic.severity.INFO
})
stream = "stdout",
parser = require("lint.parser").from_errorformat("%f:%l:%c - %m", {
source = "cspell",
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" }
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.javascript = { "eslint_d" }
lint.linters_by_ft.typescriptreact = { "eslint_d" }
lint.linters_by_ft.javascriptreact = { "eslint_d" }
end
if vim.fn.executable('luacheck') == 1 then
if vim.fn.executable "luacheck" == 1 then
lint.linters_by_ft.lua = { "luacheck" }
end
if vim.fn.executable('stylelint') == 1 then
if vim.fn.executable "stylelint" == 1 then
lint.linters_by_ft.scss = { "stylelint" }
end
if vim.fn.executable('rubocop') == 1 then
if vim.fn.executable "rubocop" == 1 then
lint.linters_by_ft.ruby = { "rubocop" }
end
if vim.fn.executable('erb_lint') == 1 then
if vim.fn.executable "erb_lint" == 1 then
lint.linters_by_ft.eruby = { "erb_lint" }
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
-- mainly to disable spell checking in vim lsp popup buffers.
if should_lint then
table.insert(linters, 'cspell')
table.insert(linters, "cspell")
end
lint.try_lint(linters)
end,
})

View file

@ -1,7 +1,7 @@
local lspconfig = require "lspconfig"
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 = {
-- 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",
desc = "Clear All the References",
})
end
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" }
)
local border = 'rounded'
local border = "rounded"
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/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.diagnostic.config({
vim.diagnostic.config {
float = {
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_autocmd({ "CursorHold", "CursorHoldI" }, {
callback = function()

View file

@ -23,4 +23,3 @@ vim.api.nvim_create_user_command("PrrGoToLine", function()
vim.cmd("e " .. target_file)
vim.fn.cursor(target_line - 1, column)
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 },
indent = { enable = false },
rainbow = { enable = true },
@ -8,6 +8,12 @@ require'nvim-treesitter.configs'.setup {
additional_vim_regex_highlighting = true,
},
ensure_installed = {
"typescript", "javascript", "tsx", "php", "html", "go", "clojure"
"typescript",
"javascript",
"tsx",
"php",
"html",
"go",
"clojure",
},
}