this hurts

This commit is contained in:
Sakooooo 2023-08-23 16:58:07 +00:00
parent 05b0210dae
commit e2c332c3ae
Signed by: sako
GPG key ID: FE52FD65B76E4751
2 changed files with 78 additions and 74 deletions

View file

@ -1,42 +1,47 @@
-- Utilities for creating configurations -- Utilities for creating configurations
local util = require "formatter.util" local util = require("formatter.util")
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands -- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup { require("formatter").setup({
-- Enable or disable logging -- Enable or disable logging
logging = true, logging = true,
log_level = vim.log.levels.WARN, log_level = vim.log.levels.WARN,
filetype = { filetype = {
lua = { lua = {
require("formatter.filetypes.lua").stylua, require("formatter.filetypes.lua").stylua,
function() function()
return { return {
exe = "stylua", exe = "stylua",
args = { args = {
"--search-parent-directories", "--search-parent-directories",
"--stdin-filepath", "--stdin-filepath",
util.escape_path(util.get_current_buffer_file_path()), util.escape_path(util.get_current_buffer_file_path()),
"--", "--",
"-", "-",
}, },
stdin = true, stdin = true,
} }
end end,
}, },
nix = { nix = {
require("formatter.filetypes.nix").alejandra, require("formatter.filetypes.nix").alejandra,
function() function()
return { return {
exe = "alejandra", exe = "alejandra",
stdin = true, stdin = true,
args = { args = {
"--quiet" "--quiet",
}, },
} }
end end,
}, },
["*"] = { ["*"] = {
require("formatter.filetypes.any").remove_trailing_whitespace require("formatter.filetypes.any").remove_trailing_whitespace,
} },
} },
} })
vim.api.nvim_command("augroup FormatAutogroup")
vim.api.nvim_command("autocmd!")
vim.api.nvim_command("autocmd BufWritePost * FormatWrite")
vim.api.nvim_command("augroup END")

View file

@ -6,74 +6,73 @@ require("mason").setup()
require("mason-lspconfig").setup() require("mason-lspconfig").setup()
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, {}) vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, {})
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, {}) vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, {})
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {}) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {})
vim.keymap.set("n", "gr", require("telescope.builtin").lsp_references, {}) vim.keymap.set("n", "gr", require("telescope.builtin").lsp_references, {})
vim.keymap.set("n", "K", vim.lsp.buf.hover, {}) vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
end end
-- enable autocomplete -- enable autocomplete
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- funny lsp config stuff -- funny lsp config stuff
require('lspconfig').nil_ls.setup({ require("lspconfig").nil_ls.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").lua_ls.setup({ require("lspconfig").lua_ls.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").omnisharp.setup({ require("lspconfig").omnisharp.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").cmake.setup({ require("lspconfig").cmake.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").clangd.setup({ require("lspconfig").clangd.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").tsserver.setup({ require("lspconfig").tsserver.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").html.setup({ require("lspconfig").html.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").eslint.setup({ require("lspconfig").eslint.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
vim.api.nvim_create_autocmd("BufWritePre", { vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr, buffer = bufnr,
command = "EslintFixAll", command = "EslintFixAll",
}) })
end, end,
}) })
require("lspconfig").pyright.setup({ require("lspconfig").pyright.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require("lspconfig").cssls.setup({ require("lspconfig").cssls.setup({
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
}) })
require('lspconfig')['hls'].setup { require("lspconfig")["hls"].setup({
filetypes = { 'haskell', 'lhaskell', 'cabal' }, filetypes = { "haskell", "lhaskell", "cabal" },
} })