From a8f1f6e8f7b2739e12307495d1ff3038d22e2860 Mon Sep 17 00:00:00 2001 From: Gerrit Pannek Date: Wed, 15 Mar 2023 13:06:11 +0100 Subject: [PATCH] change(nvim): changed config for nvchad v2.0 --- configfile/nvim/lua/custom/chadrc.lua | 20 +---- .../nvim/lua/custom/configs/lspconfig.lua | 17 ++++ .../nvim/lua/custom/configs/null-ls.lua | 25 ++++++ .../nvim/lua/custom/configs/overrides.lua | 77 +++++++++++++++++++ configfile/nvim/lua/custom/init.lua | 10 +-- configfile/nvim/lua/custom/mappings.lua | 12 +++ configfile/nvim/lua/custom/plugins.lua | 28 +++++++ configfile/nvim/lua/custom/plugins/init.lua | 42 ---------- 8 files changed, 166 insertions(+), 65 deletions(-) create mode 100644 configfile/nvim/lua/custom/configs/lspconfig.lua create mode 100644 configfile/nvim/lua/custom/configs/null-ls.lua create mode 100644 configfile/nvim/lua/custom/configs/overrides.lua create mode 100644 configfile/nvim/lua/custom/mappings.lua create mode 100644 configfile/nvim/lua/custom/plugins.lua delete mode 100644 configfile/nvim/lua/custom/plugins/init.lua diff --git a/configfile/nvim/lua/custom/chadrc.lua b/configfile/nvim/lua/custom/chadrc.lua index cd732a6..50e75d3 100644 --- a/configfile/nvim/lua/custom/chadrc.lua +++ b/configfile/nvim/lua/custom/chadrc.lua @@ -10,24 +10,8 @@ M.ui = { theme = "tokyonight" } -M.plugins = require "custom.plugins" - -M.mappings = { - teleskope = { - n = { - ["?"] = { " Telescope keymaps ", "show keys" }, - } - - } --- -- custom = {}, -- custom user mappings --- --- custom = { --- cheatsheet = "ch", --- line_number_toggle = "n", -- toggle line number --- update_nvchad = "uu", --- new_tab = "t", --- }, -} +M.plugins = "custom.plugins" +M.mappings = require "custom.mappings" return M diff --git a/configfile/nvim/lua/custom/configs/lspconfig.lua b/configfile/nvim/lua/custom/configs/lspconfig.lua new file mode 100644 index 0000000..d143d14 --- /dev/null +++ b/configfile/nvim/lua/custom/configs/lspconfig.lua @@ -0,0 +1,17 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require "lspconfig" + +-- if you just want default config for the servers then put them in a table +local servers = { "ansiblels", "bashls", "pylsp", "yamlls", "marksman", "terraform_lsp", "jsonls" } + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end + +-- +-- lspconfig.pyright.setup { blabla} diff --git a/configfile/nvim/lua/custom/configs/null-ls.lua b/configfile/nvim/lua/custom/configs/null-ls.lua new file mode 100644 index 0000000..cfdb3e0 --- /dev/null +++ b/configfile/nvim/lua/custom/configs/null-ls.lua @@ -0,0 +1,25 @@ +local present, null_ls = pcall(require, "null-ls") + +if not present then + return +end + +local b = null_ls.builtins + +local sources = { + + -- webdev stuff + b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast! + b.formatting.prettier.with { filetypes = { "html", "markdown", "css" } }, -- so prettier works only on these filetypes + + -- Lua + b.formatting.stylua, + + -- cpp + b.formatting.clang_format, +} + +null_ls.setup { + debug = true, + sources = sources, +} diff --git a/configfile/nvim/lua/custom/configs/overrides.lua b/configfile/nvim/lua/custom/configs/overrides.lua new file mode 100644 index 0000000..3523ee4 --- /dev/null +++ b/configfile/nvim/lua/custom/configs/overrides.lua @@ -0,0 +1,77 @@ +local M = {} + +M.treesitter = { + ensure_installed = { + "diff", + "gitcommit", + "git_rebase", + "yaml", + "toml", + "dockerfile", + "python", + "go", + "php", + "make", + "jq", + "bash", + "json5", + "vim", + "lua", + "html", + "css", + "javascript", + "c", + "markdown", + "markdown_inline", + }, + indent = { + enable = true, + disable = { + "python" + }, + }, +} + +M.mason = { + ensure_installed = { + -- LSP: + "yaml-language-server", + "python-lsp-server", + "lua-language-server", + "bash-language-server", + "ansible-language-server", + "dockerfile-language-server", + "json-lsp", + "marksman", + "terraform-ls", + + -- Formater: + "yamlfmt", + "shfmt", + "fixjson", + + -- Linter: + "gitlint", + "yamllint", + "prettier", + "markdownlint", + }, +} + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} + +return M diff --git a/configfile/nvim/lua/custom/init.lua b/configfile/nvim/lua/custom/init.lua index 0ac1642..a871720 100644 --- a/configfile/nvim/lua/custom/init.lua +++ b/configfile/nvim/lua/custom/init.lua @@ -1,14 +1,14 @@ -- AutoCMD: ---vim.cmd([[ +-- vim.cmd([[ -- stuff -- stuff ---]]) +-- ]]) -- Open a file from its last left off position -vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] +-- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] -- uncomment this if you want to open nvim with a dir -vim.cmd [[ autocmd BufEnter * if &buftype != "terminal" | lcd %:p:h | endif ]] +-- vim.cmd [[ autocmd BufEnter * if &buftype != "terminal" | lcd %:p:h | endif ]] -- File extension specific tabbing -vim.cmd [[ autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 ]] +-- vim.cmd [[ autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 ]] diff --git a/configfile/nvim/lua/custom/mappings.lua b/configfile/nvim/lua/custom/mappings.lua new file mode 100644 index 0000000..9ce068a --- /dev/null +++ b/configfile/nvim/lua/custom/mappings.lua @@ -0,0 +1,12 @@ +---@type MappingsTable +local M = {} + +M.general = { + n = { + [";"] = { ":", "enter command mode", opts = { nowait = true } }, + }, +} + +-- more keybinds! + +return M diff --git a/configfile/nvim/lua/custom/plugins.lua b/configfile/nvim/lua/custom/plugins.lua new file mode 100644 index 0000000..27dd56a --- /dev/null +++ b/configfile/nvim/lua/custom/plugins.lua @@ -0,0 +1,28 @@ +local overrides = require("custom.configs.overrides") + +---@type NvPluginSpec[] +local plugins = { + { + "neovim/nvim-lspconfig", + dependencies = { + -- format & linting + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + require "custom.configs.null-ls" + end, + }, + }, + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, -- Override to setup mason-lspconfig + }, + -- overrde plugin configs + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, +} + +return plugins diff --git a/configfile/nvim/lua/custom/plugins/init.lua b/configfile/nvim/lua/custom/plugins/init.lua deleted file mode 100644 index 87744d4..0000000 --- a/configfile/nvim/lua/custom/plugins/init.lua +++ /dev/null @@ -1,42 +0,0 @@ --- Additional Plugins --- -return { - ['cappyzawa/trim.nvim'] = { - override_options = { - config = function() - require('trim').setup({ - -- if you want to ignore markdown file. - -- you can specify filetypes. - disable = {"markdown"}, - - -- if you want to ignore space of top - patterns = { - [[%s/\s\+$//e]], -- remove unwanted spaces - [[%s/\($\n\s*\)\+\%$//]], -- trim last line - [[%s/\%^\n\+//]], -- trim first line - -- [[%s/\(\n\n\)\n\+/\1/]], -- replace multiple blank lines with a single line - }, - }) - end - } - }, - - -- disable dashboard - ['goolord/alpha-nvim'] = { disable = true }, - - -- UI - ["NvChad/ui"] = { - override_options = { - statusline = { - separator_style = "arrow", -- default/round/block/arrow - overriden_modules = nil, - }, - -- lazyload it when there are 1+ buffers - tabufline = { - enabled = true, - lazyload = true, - overriden_modules = nil, - }, - } - }, -}