From fb3c96d50d625db725940625120012c75afc17f6 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Fri, 14 Jun 2024 19:06:50 +0200 Subject: feat: Initial commit --- lua/gabrielgio/dap.lua | 32 +++++++++++++++++++++++++ lua/gabrielgio/gitsigns.lua | 4 ++++ lua/gabrielgio/go.lua | 16 +++++++++++++ lua/gabrielgio/init.lua | 12 ++++++++++ lua/gabrielgio/key.lua | 24 +++++++++++++++++++ lua/gabrielgio/lsp.lua | 45 ++++++++++++++++++++++++++++++++++ lua/gabrielgio/mini.lua | 11 +++++++++ lua/gabrielgio/neovide.lua | 21 ++++++++++++++++ lua/gabrielgio/settable.lua | 56 +++++++++++++++++++++++++++++++++++++++++++ lua/gabrielgio/so.lua | 6 +++++ lua/gabrielgio/telescope.lua | 30 +++++++++++++++++++++++ lua/gabrielgio/term.lua | 7 ++++++ lua/gabrielgio/treesitter.lua | 6 +++++ lua/gabrielgio/trouble.lua | 15 ++++++++++++ lua/gabrielgio/undotree.lua | 3 +++ 15 files changed, 288 insertions(+) create mode 100644 lua/gabrielgio/dap.lua create mode 100644 lua/gabrielgio/gitsigns.lua create mode 100644 lua/gabrielgio/go.lua create mode 100644 lua/gabrielgio/init.lua create mode 100644 lua/gabrielgio/key.lua create mode 100644 lua/gabrielgio/lsp.lua create mode 100644 lua/gabrielgio/mini.lua create mode 100644 lua/gabrielgio/neovide.lua create mode 100644 lua/gabrielgio/settable.lua create mode 100644 lua/gabrielgio/so.lua create mode 100644 lua/gabrielgio/telescope.lua create mode 100644 lua/gabrielgio/term.lua create mode 100644 lua/gabrielgio/treesitter.lua create mode 100644 lua/gabrielgio/trouble.lua create mode 100644 lua/gabrielgio/undotree.lua (limited to 'lua/gabrielgio') diff --git a/lua/gabrielgio/dap.lua b/lua/gabrielgio/dap.lua new file mode 100644 index 0000000..2534c7a --- /dev/null +++ b/lua/gabrielgio/dap.lua @@ -0,0 +1,32 @@ +local dap = require("dap") +local key = require("gabrielgio.key") +local dapgo = require("dap-go") + +dapgo.setup({delve = {build_flags = "-tags=unit,integration,e2e"}}) + +key.nnoremap("", ":lua require'dap'.continue()") +key.nnoremap("", ":lua require'dap'.step_over()") +key.nnoremap("", ":lua require'dap'.step_into()") +key.nnoremap("", ":lua require'dap'.step_out()") +key.nnoremap("b", ":lua require'dap'.toggle_breakpoint()") +key.nnoremap("B", ":lua require'dap'.set_breakpoint(vim.fn.input('Condition: '))") +key.nnoremap("dt", ":lua require'dap-go'.debug_test()") +key.nnoremap("dr", ":lua require'dap'.repl.open()") + +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "-i", "dap" } +} + +dap.configurations.c = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + }, +} diff --git a/lua/gabrielgio/gitsigns.lua b/lua/gabrielgio/gitsigns.lua new file mode 100644 index 0000000..306e650 --- /dev/null +++ b/lua/gabrielgio/gitsigns.lua @@ -0,0 +1,4 @@ +local gitsigns = require("gitsigns") + + +gitsigns.setup() diff --git a/lua/gabrielgio/go.lua b/lua/gabrielgio/go.lua new file mode 100644 index 0000000..ae442b4 --- /dev/null +++ b/lua/gabrielgio/go.lua @@ -0,0 +1,16 @@ +local key = require("gabrielgio.key") + +vim.g["go_def_mode"] = "gopls" +vim.g["go_info_mode"] = "gopls" +key.nnoremap("r", ":GoReferrers") +key.nnoremap("a", ":GoAlternate") +key.nnoremap("s", ":GoRename") +key.nnoremap("i", ":GoImplements") +key.nnoremap("o", ":GoIfErr") +key.nnoremap("gs", ":GoDebugStart .") +key.nnoremap("gc", ":GoDebugContinue") +key.nnoremap("gb", ":GoBuild") +key.nnoremap("gr", ":GoDebugRestart") +key.nnoremap("gn", ":GoRun") +key.nnoremap("gt", ":GoTest") +key.nnoremap("ge", ":exec \":GoDebugPrint \".input(\"eval: \")") diff --git a/lua/gabrielgio/init.lua b/lua/gabrielgio/init.lua new file mode 100644 index 0000000..a00b425 --- /dev/null +++ b/lua/gabrielgio/init.lua @@ -0,0 +1,12 @@ +require("gabrielgio.lsp") +require("gabrielgio.settable") +require("gabrielgio.mini") +require("gabrielgio.go") +require("gabrielgio.telescope") +require("gabrielgio.treesitter") +require("gabrielgio.undotree") +require("gabrielgio.so") +require("gabrielgio.trouble") +require("gabrielgio.dap") +require("gabrielgio.term") +require("gabrielgio.neovide") diff --git a/lua/gabrielgio/key.lua b/lua/gabrielgio/key.lua new file mode 100644 index 0000000..ed683b1 --- /dev/null +++ b/lua/gabrielgio/key.lua @@ -0,0 +1,24 @@ +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 +end + +local nmap = bind("n", {noremap = false}) +local nnoremap = bind("n") +local vnoremap = bind("v") +local xnoremap = bind("x") +local inoremap = bind("i") +local tnoremap = bind("t") + +return { + nmap = nmap, + nnoremap = nnoremap, + tnoremap = tnoremap, + vnoremap = vnoremap, + xnoremap = xnoremap, + inoremap = inoremap +} diff --git a/lua/gabrielgio/lsp.lua b/lua/gabrielgio/lsp.lua new file mode 100644 index 0000000..3856db9 --- /dev/null +++ b/lua/gabrielgio/lsp.lua @@ -0,0 +1,45 @@ +local lsp_config = require("lspconfig") + +local function set_key(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 +end + +local function setup(f) + return f({capabilities = capabilities, on_attach = on_attach}) +end + +local function load_all(l) + 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.lua_ls.setup, + lsp_config.pylsp.setup +}) + +lsp_config.gopls.setup({ + capabilities = capabilities, + cmd_env = {GOFLAGS = "-tags=unit,integration,e2e"}, + on_attach = on_attach +}) diff --git a/lua/gabrielgio/mini.lua b/lua/gabrielgio/mini.lua new file mode 100644 index 0000000..28b49b0 --- /dev/null +++ b/lua/gabrielgio/mini.lua @@ -0,0 +1,11 @@ +local cmp = require("mini.completion") +local diff = require("mini.diff") +local status = require("mini.statusline") + +cmp.setup() +diff.setup({ + view = { + style = 'sign' + } +}) +status.setup() diff --git a/lua/gabrielgio/neovide.lua b/lua/gabrielgio/neovide.lua new file mode 100644 index 0000000..cb71243 --- /dev/null +++ b/lua/gabrielgio/neovide.lua @@ -0,0 +1,21 @@ +local key = require("gabrielgio.key") + +if not vim.g.neovide then + return +end + +vim.g.neovide_scale_factor = 1 +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 +end + +key.nnoremap("-", function() + change_scale_factor(1.10) +end) + +key.nnoremap("=", function() + change_scale_factor(1/1.10) +end) diff --git a/lua/gabrielgio/settable.lua b/lua/gabrielgio/settable.lua new file mode 100644 index 0000000..d70dfa1 --- /dev/null +++ b/lua/gabrielgio/settable.lua @@ -0,0 +1,56 @@ +local key = require("gabrielgio.key") +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.hidden = true +vim.opt.errorbells = false +vim.opt.exrc = true +vim.opt.relativenumber = true +vim.opt.hlsearch = true +vim.opt.nu = true +vim.opt.wrap = false +vim.opt.smartcase = true +vim.opt.ignorecase = true +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = "/home/gabrielgio/.local/share/nvim/undodir" +vim.opt.undofile = true +vim.opt.incsearch = true +vim.opt.termguicolors = true +vim.opt.scrolloff = 8 +vim.opt.showmode = false +vim.opt.colorcolumn = "80" +vim.opt.signcolumn = "yes" +vim.opt.background = "light" +vim.opt.completeopt = {"menu", "menuone", "noselect"} +vim.opt.clipboard = (vim.opt.clipboard + "unnamedplus") +vim.opt.spelllang = {"en", "pt_br", "de"} +vim.opt.list = true +vim.opt.listchars = { + eol = "\194\172", + tab = ">\194\183", + trail = "~", + extends = ">", + precedes = "<", + space = "." +} +vim.opt.wildignore = (vim.opt.wildignore + "**/.git/*") +vim.g.mapleader = " " +vim.opt.updatetime = 100 +vim.opt.foldmethod = "expr" +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +vim.opt.foldenable = false +key.nnoremap("w", "w") +vim.cmd("colorscheme edge") +vim.o.background = "light" + +vim.g.loaded = 1 +vim.g.loaded_netrwPlugin = 1 +vim.g.CtrlSpaceDefaultMappingKey = " " +vim.g.maplocalleader = ";" + +vim.g.cmake_build_dir = "build" +vim.g.cmake_build_type = "Debug" diff --git a/lua/gabrielgio/so.lua b/lua/gabrielgio/so.lua new file mode 100644 index 0000000..df04319 --- /dev/null +++ b/lua/gabrielgio/so.lua @@ -0,0 +1,6 @@ +local key = require("gabrielgio.key") +local symbols = require("symbols-outline") + +key.nnoremap("to", ":SymbolsOutline") + +symbols.setup() diff --git a/lua/gabrielgio/telescope.lua b/lua/gabrielgio/telescope.lua new file mode 100644 index 0000000..257a42e --- /dev/null +++ b/lua/gabrielgio/telescope.lua @@ -0,0 +1,30 @@ +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.load_extension("file_browser") + +key.nnoremap("ff", builtins.find_files) +key.nnoremap("fs", builtins.live_grep) +key.nnoremap("fd", ":Telescope buffers") +key.nnoremap("n", ":Telescope file_browser") +key.nnoremap("m", ":Telescope file_browser path=%:p:h select_buffer=true") diff --git a/lua/gabrielgio/term.lua b/lua/gabrielgio/term.lua new file mode 100644 index 0000000..0172fbe --- /dev/null +++ b/lua/gabrielgio/term.lua @@ -0,0 +1,7 @@ +local key = require("gabrielgio.key") + +key.nnoremap("", ":Neogit kind=replace") +key.nnoremap("", ":ToggleTerminal") +key.tnoremap("", ":ToggleTerminal") +key.tnoremap("", "") +key.tnoremap("", ":Neogit kind=replace") diff --git a/lua/gabrielgio/treesitter.lua b/lua/gabrielgio/treesitter.lua new file mode 100644 index 0000000..4091805 --- /dev/null +++ b/lua/gabrielgio/treesitter.lua @@ -0,0 +1,6 @@ +local tree_sitter = require("nvim-treesitter.configs") + +tree_sitter.setup({ + ensure_installed = {"c", "go"}, + highlight = {enable = true} +}) diff --git a/lua/gabrielgio/trouble.lua b/lua/gabrielgio/trouble.lua new file mode 100644 index 0000000..67c4938 --- /dev/null +++ b/lua/gabrielgio/trouble.lua @@ -0,0 +1,15 @@ +local trouble = require("trouble") + +trouble.setup{ + fold_open = "v", + fold_closed = ">", + signs = { + error = "error", + warning = "warn", + hint = "hint", + information = "info" + }, + indent_lines = false, + icons = false, + use_diagnostic_signs = false +} diff --git a/lua/gabrielgio/undotree.lua b/lua/gabrielgio/undotree.lua new file mode 100644 index 0000000..c117df2 --- /dev/null +++ b/lua/gabrielgio/undotree.lua @@ -0,0 +1,3 @@ +local key = require("gabrielgio.key") + +key.nnoremap("ut", ":UndotreeToggle") -- cgit v1.2.3