From 6f2e38e183bcf1faa864ebb11b162c99fd4a0130 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Mon, 2 Sep 2024 16:18:16 +0200 Subject: feat: Sync --- lua/gabrielgio/dap.lua | 28 +++++++++--------- lua/gabrielgio/formatter.lua | 17 +++++++++++ lua/gabrielgio/gitsigns.lua | 1 - lua/gabrielgio/go.lua | 2 +- lua/gabrielgio/init.lua | 36 ++++++++++++++--------- lua/gabrielgio/key.lua | 26 ++++++++--------- lua/gabrielgio/lazy.lua | 48 +++++++++++------------------- lua/gabrielgio/linter.lua | 13 +++++++++ lua/gabrielgio/lsp.lua | 68 ++++++++++++++++++++++--------------------- lua/gabrielgio/mini.lua | 6 ++-- lua/gabrielgio/neovide.lua | 8 ++--- lua/gabrielgio/settable.lua | 23 +++++++-------- lua/gabrielgio/telescope.lua | 36 +++++++++++------------ lua/gabrielgio/treesitter.lua | 4 +-- lua/gabrielgio/trouble.lua | 26 ++++++++--------- 15 files changed, 183 insertions(+), 159 deletions(-) create mode 100644 lua/gabrielgio/formatter.lua create mode 100644 lua/gabrielgio/linter.lua (limited to 'lua/gabrielgio') diff --git a/lua/gabrielgio/dap.lua b/lua/gabrielgio/dap.lua index 238a1bc..c5f316b 100644 --- a/lua/gabrielgio/dap.lua +++ b/lua/gabrielgio/dap.lua @@ -10,20 +10,20 @@ key.nnoremap("B", ":lua require'dap'.set_breakpoint(vim.fn.input('Condit key.nnoremap("dr", ":lua require'dap'.repl.open()") dap.adapters.delve = { - type = "server", - host = "127.0.0.1", - port = 2345, - } + type = "server", + host = "127.0.0.1", + port = 2345, +} dap.configurations.go = { - { - type = "delve", - name = "remote", - mode = "remote", - request = "attach", - connect = { - host = "127.0.0.1", - port = "2345", - }, - }, + { + type = "delve", + name = "remote", + mode = "remote", + request = "attach", + connect = { + host = "127.0.0.1", + port = "2345", + }, + }, } diff --git a/lua/gabrielgio/formatter.lua b/lua/gabrielgio/formatter.lua new file mode 100644 index 0000000..68c8bac --- /dev/null +++ b/lua/gabrielgio/formatter.lua @@ -0,0 +1,17 @@ +local formatter = require("formatter") + +formatter.setup({ + filetype = { + nix = { require("formatter.filetypes.nix").alejandra }, + lua = { require("formatter.filetypes.lua").stylua }, + }, + ["*"] = { + require("formatter.filetypes.any").remove_trailing_whitespace, + }, +}) + +vim.api.nvim_create_augroup("__formatter__", { clear = true }) +vim.api.nvim_create_autocmd("BufWritePost", { + group = "__formatter__", + command = ":FormatWrite", +}) diff --git a/lua/gabrielgio/gitsigns.lua b/lua/gabrielgio/gitsigns.lua index 306e650..a238e52 100644 --- a/lua/gabrielgio/gitsigns.lua +++ b/lua/gabrielgio/gitsigns.lua @@ -1,4 +1,3 @@ local gitsigns = require("gitsigns") - gitsigns.setup() diff --git a/lua/gabrielgio/go.lua b/lua/gabrielgio/go.lua index ae442b4..e0b27b7 100644 --- a/lua/gabrielgio/go.lua +++ b/lua/gabrielgio/go.lua @@ -13,4 +13,4 @@ key.nnoremap("gb", ":GoBuild") key.nnoremap("gr", ":GoDebugRestart") key.nnoremap("gn", ":GoRun") key.nnoremap("gt", ":GoTest") -key.nnoremap("ge", ":exec \":GoDebugPrint \".input(\"eval: \")") +key.nnoremap("ge", ':exec ":GoDebugPrint ".input("eval: ")') diff --git a/lua/gabrielgio/init.lua b/lua/gabrielgio/init.lua index d2eafa8..2c146cf 100644 --- a/lua/gabrielgio/init.lua +++ b/lua/gabrielgio/init.lua @@ -1,17 +1,25 @@ -local mini_deps = require('mini.deps') +local mini_deps = require("mini.deps") local now, later = mini_deps.now, mini_deps.later -now(function() require("gabrielgio.settable") end) -now(function() require("gabrielgio.lsp") end) -now(function() require("gabrielgio.lazy") end) +local function require_func(v) + return function() + require(v) + end +end -later(function() require("gabrielgio.treesitter") end) -later(function() require("gabrielgio.mini") end) -later(function() require("gabrielgio.go") end) -later(function() require("gabrielgio.telescope") end) -later(function() require("gabrielgio.undotree") end) -later(function() require("gabrielgio.so") end) -later(function() require("gabrielgio.trouble") end) -later(function() require("gabrielgio.dap") end) -later(function() require("gabrielgio.term") end) -later(function() require("gabrielgio.neovide") end) +now(require_func("gabrielgio.settable")) +now(require_func("gabrielgio.lsp")) +now(require_func("gabrielgio.lazy")) + +later(require_func("gabrielgio.linter")) +later(require_func("gabrielgio.formatter")) +later(require_func("gabrielgio.treesitter")) +later(require_func("gabrielgio.mini")) +later(require_func("gabrielgio.go")) +later(require_func("gabrielgio.telescope")) +later(require_func("gabrielgio.undotree")) +later(require_func("gabrielgio.so")) +later(require_func("gabrielgio.trouble")) +later(require_func("gabrielgio.dap")) +later(require_func("gabrielgio.term")) +later(require_func("gabrielgio.neovide")) diff --git a/lua/gabrielgio/key.lua b/lua/gabrielgio/key.lua index ed683b1..9219a3a 100644 --- a/lua/gabrielgio/key.lua +++ b/lua/gabrielgio/key.lua @@ -1,13 +1,13 @@ local function bind(op, outer_opts) - local outer_opts0 = (outer_opts or {noremap = true}) - local function lo(lhs, rhs, opts) - local opts0 = vim.tbl_extend("force", outer_opts0, (opts or {})) - return vim.keymap.set(op, lhs, rhs, opts0) - end - return lo + local outer_opts0 = (outer_opts or { noremap = true }) + local function lo(lhs, rhs, opts) + local opts0 = vim.tbl_extend("force", outer_opts0, (opts or {})) + return vim.keymap.set(op, lhs, rhs, opts0) + end + return lo end -local nmap = bind("n", {noremap = false}) +local nmap = bind("n", { noremap = false }) local nnoremap = bind("n") local vnoremap = bind("v") local xnoremap = bind("x") @@ -15,10 +15,10 @@ local inoremap = bind("i") local tnoremap = bind("t") return { - nmap = nmap, - nnoremap = nnoremap, - tnoremap = tnoremap, - vnoremap = vnoremap, - xnoremap = xnoremap, - inoremap = inoremap + nmap = nmap, + nnoremap = nnoremap, + tnoremap = tnoremap, + vnoremap = vnoremap, + xnoremap = xnoremap, + inoremap = inoremap, } diff --git a/lua/gabrielgio/lazy.lua b/lua/gabrielgio/lazy.lua index 42ab567..93a7b0a 100644 --- a/lua/gabrielgio/lazy.lua +++ b/lua/gabrielgio/lazy.lua @@ -1,35 +1,21 @@ -- this file is an amalgamation of configurations that don't have its own -- config file and will be lazily loaded -require('gitblame').setup() -require('neogit').setup() -require('formatter').setup() +require("gitblame").setup() +require("neogit").setup() require("mason").setup() -require("mason-lspconfig").setup { - ensure_installed = { - "cssls", - "emmet_ls", - "gopls", - "html", - "lua_ls", - "pylsp", - "rust_analyzer", - "tsserver", - "zls" --- "clangd" not working on alpine - }, -} - -local lint = require('lint') - -lint.linters_by_ft = { - go = {"golangcilint"}, - lua = {"luacheck"}, - javascript = {"prettier"}, -} - -vim.api.nvim_create_autocmd({ "BufWritePost" }, { - callback = function() - lint.try_lint() - end, +require("mason-lspconfig").setup({ + ensure_installed = { + "buf", + "cssls", + "emmet_ls", + "gopls", + "html", + "lua_ls", + "nixd", + "pylsp", + "rust_analyzer", + "tsserver", + "zls", + -- "clangd" not working on alpine + }, }) - diff --git a/lua/gabrielgio/linter.lua b/lua/gabrielgio/linter.lua new file mode 100644 index 0000000..c2d4503 --- /dev/null +++ b/lua/gabrielgio/linter.lua @@ -0,0 +1,13 @@ +local lint = require("lint") + +lint.linters_by_ft = { + go = { "golangcilint" }, + lua = { "luacheck" }, + javascript = { "prettier" }, +} + +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + callback = function() + lint.try_lint() + end, +}) diff --git a/lua/gabrielgio/lsp.lua b/lua/gabrielgio/lsp.lua index 5ce2ed5..d848859 100644 --- a/lua/gabrielgio/lsp.lua +++ b/lua/gabrielgio/lsp.lua @@ -1,55 +1,57 @@ local lsp_config = require("lspconfig") local function set_key(mode, keys, v, opts) - return vim.keymap.set(mode, keys, v, opts) + return vim.keymap.set(mode, keys, v, opts) end local function on_attach(client, bufnr) - do - local bufopts = {noremap = true, silent = true, buffer = bufnr} - set_key("n", "gD", vim.lsp.buf.declaration, bufopts) - set_key("n", "gd", vim.lsp.buf.definition, bufopts) - set_key("n", "K", vim.lsp.buf.hover, bufopts) - set_key("n", "gi", vim.lsp.buf.implementation, bufopts) - set_key("n", "", vim.lsp.buf.signature_help, bufopts) - set_key("n", "rn", vim.lsp.buf.declaration, bufopts) - set_key("n", "ca", vim.lsp.buf.code_action, bufopts) - set_key("n", "f", vim.lsp.buf.formatting, bufopts) - end - return bufnr + do + local bufopts = { noremap = true, silent = true, buffer = bufnr } + set_key("n", "gD", vim.lsp.buf.declaration, bufopts) + set_key("n", "gd", vim.lsp.buf.definition, bufopts) + set_key("n", "K", vim.lsp.buf.hover, bufopts) + set_key("n", "gi", vim.lsp.buf.implementation, bufopts) + set_key("n", "", vim.lsp.buf.signature_help, bufopts) + set_key("n", "rn", vim.lsp.buf.declaration, bufopts) + set_key("n", "ca", vim.lsp.buf.code_action, bufopts) + set_key("n", "f", vim.lsp.buf.formatting, bufopts) + end + return bufnr end local function setup(f) - return f({on_attach = on_attach}) + return f({ on_attach = on_attach }) end local function load_all(l) - for _, v in ipairs(l) do setup(v) end - return nil + for _, v in ipairs(l) do + setup(v) + end + return nil end load_all({ - lsp_config.rust_analyzer.setup, - lsp_config.clangd.setup, - lsp_config.cssls.setup, - lsp_config.html.setup, - lsp_config.emmet_ls.setup, - lsp_config.pylsp.setup, - lsp_config.zls.setup, - lsp_config.tsserver.setup + lsp_config.rust_analyzer.setup, + lsp_config.clangd.setup, + lsp_config.cssls.setup, + lsp_config.html.setup, + lsp_config.emmet_ls.setup, + lsp_config.pylsp.setup, + lsp_config.zls.setup, + lsp_config.tsserver.setup, }) lsp_config.gopls.setup({ - cmd_env = {GOFLAGS = "-tags=unit,integration,e2e"}, - on_attach = on_attach + cmd_env = { GOFLAGS = "-tags=unit,integration,e2e" }, + on_attach = on_attach, }) lsp_config.lua_ls.setup({ - settings = { - Lua = { - diagnostics = { - globals = {'vim'} - } - } - } + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + }, + }, }) diff --git a/lua/gabrielgio/mini.lua b/lua/gabrielgio/mini.lua index d3f8567..2c853cb 100644 --- a/lua/gabrielgio/mini.lua +++ b/lua/gabrielgio/mini.lua @@ -1,10 +1,10 @@ local diff = require("mini.diff") local cmp = require("mini.completion") local status = require("mini.statusline") -local icons = require('mini.icons') -local tabline = require('mini.tabline') +local icons = require("mini.icons") +local tabline = require("mini.tabline") -diff.setup({view = {style = 'sign'}}) +diff.setup({ view = { style = "sign" } }) cmp.setup() status.setup() icons.setup() diff --git a/lua/gabrielgio/neovide.lua b/lua/gabrielgio/neovide.lua index cb71243..5e7e5fa 100644 --- a/lua/gabrielgio/neovide.lua +++ b/lua/gabrielgio/neovide.lua @@ -1,7 +1,7 @@ local key = require("gabrielgio.key") if not vim.g.neovide then - return + return end vim.g.neovide_scale_factor = 1 @@ -9,13 +9,13 @@ vim.g.neovide_cursor_antialiasing = true vim.o.guifont = "iosevka:h20:#e-subpixelantialias" local function change_scale_factor(delta) - vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * delta + vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * delta end key.nnoremap("-", function() - change_scale_factor(1.10) + change_scale_factor(1.10) end) key.nnoremap("=", function() - change_scale_factor(1/1.10) + change_scale_factor(1 / 1.10) end) diff --git a/lua/gabrielgio/settable.lua b/lua/gabrielgio/settable.lua index 5096d3f..1307c72 100644 --- a/lua/gabrielgio/settable.lua +++ b/lua/gabrielgio/settable.lua @@ -26,17 +26,17 @@ vim.opt.showmode = false vim.opt.colorcolumn = "80" vim.opt.signcolumn = "yes" vim.opt.background = "light" -vim.opt.completeopt = {"menu", "menuone", "noselect"} +vim.opt.completeopt = { "menu", "menuone", "noselect" } vim.opt.clipboard = (vim.opt.clipboard + "unnamedplus") -vim.opt.spelllang = {"en", "pt_br", "de"} +vim.opt.spelllang = { "en", "pt_br", "de" } vim.opt.list = true vim.opt.listchars = { - eol = "\194\172", - tab = ">\194\183", - trail = "~", - extends = ">", - precedes = "<", - space = "." + eol = "\194\172", + tab = ">\194\183", + trail = "~", + extends = ">", + precedes = "<", + space = ".", } vim.opt.wildignore = (vim.opt.wildignore + "**/.git/*") vim.g.mapleader = " " @@ -45,10 +45,10 @@ vim.opt.foldmethod = "expr" vim.opt.foldexpr = "nvim_treesitter#foldexpr()" vim.opt.foldenable = false vim.o.background = "light" -if 1==1 then - vim.cmd("colorscheme edge") +if 1 == 1 then + vim.cmd("colorscheme edge") else - vim.cmd("colorscheme gruvbox") + vim.cmd("colorscheme gruvbox") end vim.g.loaded = 1 vim.g.loaded_netrwPlugin = 1 @@ -58,7 +58,6 @@ vim.g.maplocalleader = ";" vim.g.cmake_build_dir = "build" vim.g.cmake_build_type = "Debug" - key.nnoremap("w", "w") key.nnoremap("", ":bnext") key.nnoremap("", ":bprevious") diff --git a/lua/gabrielgio/telescope.lua b/lua/gabrielgio/telescope.lua index 50e07b8..b1e6cbe 100644 --- a/lua/gabrielgio/telescope.lua +++ b/lua/gabrielgio/telescope.lua @@ -2,24 +2,24 @@ local key = require("gabrielgio.key") local builtins = require("telescope.builtin") local telescope = require("telescope") -telescope.setup{ - defaults = { - file_ignore_patterns = { - "vendor/", - ".git/" - }, - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--hidden" - } - }, -} +telescope.setup({ + defaults = { + file_ignore_patterns = { + "vendor/", + ".git/", + }, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + "--hidden", + }, + }, +}) telescope.load_extension("file_browser") diff --git a/lua/gabrielgio/treesitter.lua b/lua/gabrielgio/treesitter.lua index 4091805..d15aa05 100644 --- a/lua/gabrielgio/treesitter.lua +++ b/lua/gabrielgio/treesitter.lua @@ -1,6 +1,6 @@ local tree_sitter = require("nvim-treesitter.configs") tree_sitter.setup({ - ensure_installed = {"c", "go"}, - highlight = {enable = true} + ensure_installed = { "c", "go" }, + highlight = { enable = true }, }) diff --git a/lua/gabrielgio/trouble.lua b/lua/gabrielgio/trouble.lua index f48fec4..9249c07 100644 --- a/lua/gabrielgio/trouble.lua +++ b/lua/gabrielgio/trouble.lua @@ -1,18 +1,18 @@ local key = require("gabrielgio.key") local trouble = require("trouble") -trouble.setup{ - modes = { - test = { - mode = "diagnostics", - preview = { - type = "split", - relative = "win", - position = "right", - size = 0.3, - }, - }, - }, -} +trouble.setup({ + modes = { + test = { + mode = "diagnostics", + preview = { + type = "split", + relative = "win", + position = "right", + size = 0.3, + }, + }, + }, +}) key.nnoremap("t", ":Trouble test toggle") -- cgit v1.2.3