added config files

main
Johannes Bülow 2024-01-08 16:46:02 +01:00
parent ff21a9d622
commit 8c91f4eba9
Signed by untrusted user who does not match committer: jmb
GPG Key ID: B56971CF7B8F83A6
9 changed files with 371 additions and 0 deletions

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
get:
cp -r ~/.config/nvim/lua/custom lua/
install:
cp -r lua/custom ~/.config/nvim/lua/

6
lua/custom/chadrc.lua Normal file
View File

@ -0,0 +1,6 @@
---@type ChadrcConfig
local M = {}
M.ui = {theme = 'catppuccin'}
M.plugins = "custom.plugins"
M.mappings = require "custom.mappings"
return M

View File

@ -0,0 +1,45 @@
-- local options = {
-- panel = {
-- enabled = true,
-- auto_refresh = false,
-- keymap = {
-- jump_prev = "[[",
-- jump_next = "]]",
-- accept = "<CR>",
-- refresh = "gr",
-- open = "<M-CR>"
-- },
-- layout = {
-- position = "bottom", -- | top | left | right
-- ratio = 0.4
-- },
-- },
-- suggestion = {
-- enabled = true,
-- auto_trigger = true,
-- debounce = 75,
-- keymap = {
-- accept = "<M-l>",
-- accept_word = false,
-- accept_line = "<C-j>",
-- next = "<M-]>",
-- prev = "<M-[>",
-- dismiss = "<C-]>",
-- },
-- },
-- 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

View File

@ -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,
},
}

View File

@ -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

View File

@ -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

21
lua/custom/init.lua Normal file
View File

@ -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",
},
})

57
lua/custom/mappings.lua Normal file
View File

@ -0,0 +1,57 @@
local M = {}
M.general = {
n = {
["<C-h>"] = { "<cmd> TmuxNavigateLeft<CR>", "window left" },
["<C-l>"] = { "<cmd> TmuxNavigateRight<CR>", "window right" },
["<C-j>"] = { "<cmd> TmuxNavigateDown<CR>", "window down" },
["<C-k>"] = { "<cmd> TmuxNavigateUp<CR>", "window up" },
}
}
M.dap = {
plugin = true,
n = {
["<leader>db"] = { "<cmd> DapToggleBreakpoint <CR>" },
["<leader>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 = {
["<leader>dgr"] = {
function()
require('dap-go').debug_test()
end,
"Debug go test"
},
["<leader>dgl"] = {
function()
require('dap-go').debug_last()
end,
"Debug last go test"
}
}
}
M.crates = {
plugin = true,
n = {
["<leader>rcu"] = {
function ()
require('crates').upgrade_all_crates()
end,
"update crates"
}
}
}
return M

135
lua/custom/plugins.lua Normal file
View File

@ -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["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert,
select = false,
}
M.mapping["<C-j>"] = 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