diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..12cc7a9 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +get: + cp -r ~/.config/nvim/lua/custom lua/ +install: + cp -r lua/custom ~/.config/nvim/lua/ diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua new file mode 100644 index 0000000..1071c0b --- /dev/null +++ b/lua/custom/chadrc.lua @@ -0,0 +1,6 @@ +---@type ChadrcConfig +local M = {} +M.ui = {theme = 'catppuccin'} +M.plugins = "custom.plugins" +M.mappings = require "custom.mappings" +return M diff --git a/lua/custom/configs/copilot.lua b/lua/custom/configs/copilot.lua new file mode 100644 index 0000000..a259e69 --- /dev/null +++ b/lua/custom/configs/copilot.lua @@ -0,0 +1,45 @@ +-- local options = { +-- panel = { +-- enabled = true, +-- auto_refresh = false, +-- keymap = { +-- jump_prev = "[[", +-- jump_next = "]]", +-- accept = "", +-- refresh = "gr", +-- open = "" +-- }, +-- layout = { +-- position = "bottom", -- | top | left | right +-- ratio = 0.4 +-- }, +-- }, +-- suggestion = { +-- enabled = true, +-- auto_trigger = true, +-- debounce = 75, +-- keymap = { +-- accept = "", +-- accept_word = false, +-- accept_line = "", +-- next = "", +-- prev = "", +-- dismiss = "", +-- }, +-- }, +-- filetypes = { +-- yaml = false, +-- markdown = false, +-- help = false, +-- gitcommit = false, +-- gitrebase = false, +-- hgcommit = false, +-- svn = false, +-- cvs = false, +-- ["."] = false, +-- }, +-- copilot_node_command = 'node', -- Node.js version must be > 16.x +-- server_opts_overrides = {}, +-- } +-- +-- return options diff --git a/lua/custom/configs/lspconfig.lua b/lua/custom/configs/lspconfig.lua new file mode 100644 index 0000000..ff850b4 --- /dev/null +++ b/lua/custom/configs/lspconfig.lua @@ -0,0 +1,64 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require("lspconfig") +local util = require "lspconfig/util" + +lspconfig.pylsp.setup{ + on_attach = on_attach, + capabilities = capabilities, + filetypes = {"python"}, + settings = { + pylsp = { + plugins = { + pycodestyle = { + ignore = {'W391'}, + maxLineLength = 100 + } + } + } + } +} + +lspconfig.gopls.setup { + on_attach = on_attach, + capabilities = capabilities, + cmd = {"gopls"}, + cmd_env = { + GOFLAGS = "-tags=test,e2e_test,integration_test,acceptance_test", + }, + filetypes = { "go", "gomod", "gowork", "gotmpl" }, + root_dir = util.root_pattern("go.work", "go.mod", ".git"), + settings = { + gopls = { + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + }, + }, + }, +} + +lspconfig.terraformls.setup { + on_attach = on_attach, + capabilities = capabilities, + cmd = {"terraform-ls", "serve"}, + root_dir = util.root_pattern(".terraform", ".git"), +} + +-- lspconfig.templ = { +-- default_config = { +-- cmd = { "templ", "lsp", "-log=/home/johannes/.local/share/nvim/logs/templ.log" }, +-- filetypes = { 'templ' }, +-- root_dir = util.root_pattern("go.mod", ".git"), +-- settings = {}, +-- }, +-- } +-- +lspconfig.templ.setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + }, +} diff --git a/lua/custom/configs/null-ls.lua b/lua/custom/configs/null-ls.lua new file mode 100644 index 0000000..e1ed729 --- /dev/null +++ b/lua/custom/configs/null-ls.lua @@ -0,0 +1,27 @@ +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) +local null_ls = require("null-ls") + +local opts = { + sources = { + null_ls.builtins.formatting.gofmt, + null_ls.builtins.formatting.goimports_reviser, + null_ls.builtins.formatting.golines, + }, + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ + group = augroup, + buffer = bufnr, + }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end + end, +} + +return opts diff --git a/lua/custom/configs/rust-tools.lua b/lua/custom/configs/rust-tools.lua new file mode 100644 index 0000000..9ee45ad --- /dev/null +++ b/lua/custom/configs/rust-tools.lua @@ -0,0 +1,12 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + + +local options = { + server = { + on_attach = on_attach, + capabilities = capabilities, + } +} + +return options diff --git a/lua/custom/init.lua b/lua/custom/init.lua new file mode 100644 index 0000000..bca2670 --- /dev/null +++ b/lua/custom/init.lua @@ -0,0 +1,21 @@ +vim.g.dap_virtual_text = true +vim.opt.colorcolumn = "120" + +-- Disable persistent undo +vim.opt.undofile = false + +-- Enable line wrapping at column 120 for Markdown files +vim.api.nvim_exec([[ + autocmd FileType markdown setlocal textwidth=120 + autocmd FileType markdown setlocal wrap + autocmd FileType markdown setlocal linebreak + autocmd FileType markdown setlocal spell + autocmd FileType markdown setlocal spelllang=en,de +]], false) + +-- Custom filetypes +vim.filetype.add({ + extension = { + templ = "templ", + }, +}) diff --git a/lua/custom/mappings.lua b/lua/custom/mappings.lua new file mode 100644 index 0000000..9571899 --- /dev/null +++ b/lua/custom/mappings.lua @@ -0,0 +1,57 @@ +local M = {} + +M.general = { + n = { + [""] = { " TmuxNavigateLeft", "window left" }, + [""] = { " TmuxNavigateRight", "window right" }, + [""] = { " TmuxNavigateDown", "window down" }, + [""] = { " TmuxNavigateUp", "window up" }, + } +} + +M.dap = { + plugin = true, + n = { + ["db"] = { " DapToggleBreakpoint " }, + ["dus"] = { + function () + local widgets = require('dap.ui.widgets'); + local sidebar = widgets.sidebar(widgets.scopes); + sidebar.open(); + end, + "Open debugging sidebar" + } + } +} + +M.dap_go = { + plugin = true, + n = { + ["dgr"] = { + function() + require('dap-go').debug_test() + end, + "Debug go test" + }, + ["dgl"] = { + function() + require('dap-go').debug_last() + end, + "Debug last go test" + } + } +} + +M.crates = { + plugin = true, + n = { + ["rcu"] = { + function () + require('crates').upgrade_all_crates() + end, + "update crates" + } + } +} + +return M diff --git a/lua/custom/plugins.lua b/lua/custom/plugins.lua new file mode 100644 index 0000000..47e4181 --- /dev/null +++ b/lua/custom/plugins.lua @@ -0,0 +1,135 @@ +local cmp = require "cmp" + +local plugins = { + { + "christoomey/vim-tmux-navigator", + lazy = false, + }, +-- { +-- "zbirenbaum/copilot.lua", +-- lazy = false, +-- opts = function () +-- return require "custom.configs.copilot" +-- end, +-- config = function(_, opts) +-- require("copilot").setup(opts) +-- end +-- }, + { + "anuvyklack/pretty-fold.nvim", + lazy = false, + config = function() + require("pretty-fold").setup() + end + }, + { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "gopls", + "rust-analyzer", + "python-lsp-server", + }, + }, + }, + { + "neovim/nvim-lspconfig", + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, + }, + { + "simrat39/rust-tools.nvim", + ft = "rust", + dependencies = "neovim/nvim-lspconfig", + opts = function () + return require "custom.configs.rust-tools" + end, + config = function(_, opts) + require('rust-tools').setup(opts) + end + }, + { + "jose-elias-alvarez/null-ls.nvim", + ft = "go", + opts = function() + return require "custom.configs.null-ls" + end, + }, + { + "mfussenegger/nvim-dap", + init = function() + require("core.utils").load_mappings("dap") + end + }, + { + "leoluz/nvim-dap-go", + ft = "go", + dependencies = "mfussenegger/nvim-dap", + config = function(_, opts) + require("dap-go").setup(opts) + require("core.utils").load_mappings("dap_go") + end + }, + { + "olexsmir/gopher.nvim", + ft = "go", + config = function(_, opts) + require("gopher").setup(opts) + end, + build = function() + vim.cmd [[silent! GoInstallDeps]] + end, + }, + { + 'saecki/crates.nvim', + ft = {"rust", "toml"}, + config = function(_, opts) + local crates = require('crates') + crates.setup(opts) + require('cmp').setup.buffer({ + sources = { { name = "crates" }} + }) + crates.show() + require("core.utils").load_mappings("crates") + end, + }, + { + "rust-lang/rust.vim", + ft = "rust", + init = function () + vim.g.rustfmt_autosave = 1 + end + }, + { + "theHamsta/nvim-dap-virtual-text", + lazy = false, + config = function(_, opts) + require("nvim-dap-virtual-text").setup() + end + }, + { + "hrsh7th/nvim-cmp", + opts = function() + local M = require "plugins.configs.cmp" + M.completion.completeopt = "menu,menuone,noselect" + M.mapping[""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = false, + } + + M.mapping[""] = cmp.mapping(function(_fallback) + cmp.mapping.abort() + require("copilot.suggestion").accept_line() + end, { + "i", + "s", + }) + + table.insert(M.sources, {name = "crates"}) + return M + end, + }, +} +return plugins