diff --git a/CopyNvchad.bash b/CopyNvchad.bash index 791fb75d..63bf6404 100644 --- a/CopyNvchad.bash +++ b/CopyNvchad.bash @@ -1,4 +1,4 @@ #!/bin/bash -rm -r nvchad -cp -r ~/.config/nvim/lua/custom ./nvchad +rm -r nvchad/* +cp -r ~/.config/nvim/lua/custom/* ./nvchad diff --git a/nvchad/chadrc.lua b/nvchad/chadrc.lua index 30a8e9e2..18ab9f92 100644 --- a/nvchad/chadrc.lua +++ b/nvchad/chadrc.lua @@ -1,14 +1,6 @@ local M = {} -M.plugins = { - { - "neovim/nvim-lspconfig", - config = function() - require "plugins.configs.lspconfig" - require "custom.plugins.lspconfig" - end, - }, -} +M.plugins = "custom.plugins" M.options = { user = function() diff --git a/nvchad/lspconfig.lua b/nvchad/lspconfig.lua new file mode 100644 index 00000000..b6dca16a --- /dev/null +++ b/nvchad/lspconfig.lua @@ -0,0 +1,19 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require "lspconfig" +local servers = { "tsserver", "tailwindcss", "cssls", "prismals", "gopls", "yamlls", "hls" } + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end + +lspconfig.tsserver.setup { + on_attach = function(client) + client.server_capabilities.documentFormattingProvider = false + end, +} + diff --git a/nvchad/mappings.lua b/nvchad/mappings.lua index 5fc4ba62..f37d57bc 100644 --- a/nvchad/mappings.lua +++ b/nvchad/mappings.lua @@ -22,6 +22,8 @@ M.diffview = { }, } +local lazyGitted = false + M.custom = { n = { ["fm"] = { ":lua vim.lsp.buf.format() ", "Formats the current buffer using built in LSP" }, @@ -30,11 +32,36 @@ M.custom = { ["rf"] = { ":lua require('refactoring').select_refactor()", "options" }, ["q"] = { ":lua require('harpoon.mark').add_file()" }, ["fp"] = { ":lua require('harpoon.ui').toggle_quick_menu()" }, - ["lg"] = { ":LazyGit" }, + [""] = { + function() + if lazyGitted then + require("nvterm.terminal").toggle "float" + else + lazyGitted = true + local term = require("nvterm.terminal").new "float" + -- Work around to get lazygit to work. + vim.api.nvim_chan_send(term.job_id, "lazygit\n") + end + end, + "Toggle floating terminal", + }, }, v = { ["rf"] = { ":lua require('refactoring').select_refactor()", "options" }, }, + t = { + [""] = { + function() + if lazyGitted then + require("nvterm.terminal").toggle "float" + else + lazyGitted = true + require("nvterm.terminal").toggle "float" + end + end, + "Toggle floating terminal", + }, + }, } return M diff --git a/nvchad/null-ls.lua b/nvchad/null-ls.lua new file mode 100644 index 00000000..db6ebc37 --- /dev/null +++ b/nvchad/null-ls.lua @@ -0,0 +1,24 @@ +local null_ls = require "null-ls" +local formatting = null_ls.builtins.formatting +local diagnostics = null_ls.builtins.diagnostics +local code_action = null_ls.builtins.code_actions + +local sources = { + formatting.prettierd, + formatting.stylua, + + diagnostics.eslint_d, + + code_action.eslint_d, +} + +null_ls.setup { + debug = true, + sources = sources, + + on_attach = function(client) + if client.server_capabilities.documentFormattingProvider then + vim.cmd "autocmd BufWritePre lua vim.lsp.buf.format()" + end + end, +} diff --git a/nvchad/plugins.lua b/nvchad/plugins.lua new file mode 100644 index 00000000..dd06c729 --- /dev/null +++ b/nvchad/plugins.lua @@ -0,0 +1,49 @@ +return { + { "wakatime/vim-wakatime", lazy = false }, + { + "neovim/nvim-lspconfig", + dependencies = { + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + require "custom.null-ls" + end, + }, + }, + config = function() + require "plugins.configs.lspconfig" + require "custom.lspconfig" + end, + }, + { "windwp/nvim-ts-autotag", lazy = false }, + { "lervag/vimtex", lazy = false }, + { "sindrets/diffview.nvim", lazy = false }, + { "ThePrimeagen/harpoon" }, + { "christoomey/vim-tmux-navigator", lazy = false }, + { "jose-elias-alvarez/null-ls.nvim" }, + { + "NvChad/nvterm", + config = function() + require("nvterm").setup { + terminals = { + shell = vim.o.shell, + list = {}, + type_opts = { + float = { + row = 0.1, + col = 0.1, + width = 0.8, + height = 0.8, + border = "single", + }, + horizontal = { location = "rightbelow", split_ratio = 0.3 }, + vertical = { location = "rightbelow", split_ratio = 0.5 }, + }, + }, + behavior = { + auto_insert = true, + }, + } + end, + }, +} diff --git a/nvchad/plugins/init.lua b/nvchad/plugins/init.lua deleted file mode 100644 index 52e45c9a..00000000 --- a/nvchad/plugins/init.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - ["wakatime/vim-wakatime"] = {}, - ["sbdchd/neoformat"] = {}, - ["williamboman/mason-lspconfig.nvim"] = {}, - ["neovim/nvim-lspconfig"] = { - config = function() - require "plugins.configs.lspconfig" - require "custom.plugins.lspconfig" - end, - }, - ["windwp/nvim-ts-autotag"] = { - ft = { "html", "javascriptreact", "typescriptreact", "astro" }, - after = "nvim-treesitter", - config = function() - local present, autotag = pcall(require, "nvim-ts-autotag") - - if present then - autotag.setup() - end - end, - }, - ["lervag/vimtex"] = {}, - ["sindrets/diffview.nvim"] = {}, - ["ThePrimeagen/refactoring.nvim"] = {}, - ["ThePrimeagen/harpoon"] = {}, - ["christoomey/vim-tmux-navigator"] = {}, - ["kdheepak/lazygit.nvim"] = {}, - ["jose-elias-alvarez/null-ls.nvim"] = { - config = function() - require "null-ls-config" - end, - }, -} diff --git a/nvchad/plugins/lspconfig.lua b/nvchad/plugins/lspconfig.lua deleted file mode 100644 index ea945eba..00000000 --- a/nvchad/plugins/lspconfig.lua +++ /dev/null @@ -1,44 +0,0 @@ -local on_attach = require("plugins.configs.lspconfig").on_attach -local capabilities = require("plugins.configs.lspconfig").capabilities - -local lspconfig = require "lspconfig" -local servers = { "tsserver", "tailwindcss", "cssls", "prismals", "gopls", "yamlls", "hls" } - -local null_ls = require "null-ls" -local formatting = null_ls.builtins.formatting -local diagnostics = null_ls.builtins.diagnostics -local code_action = null_ls.builtins.code_actions - -local sources = { - formatting.prettierd, - formatting.stylua, - - diagnostics.eslint_d, - - code_action.eslint_d, -} - -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - on_attach = on_attach, - capabilities = capabilities, - } -end - -lspconfig.tsserver.setup { - on_attach = function(client) - client.server_capabilities.documentFormattingProvider = false - -- client.resolved_capabilities.document_formatting = false - end, -} - -null_ls.setup { - debug = true, - sources = sources, - - on_attach = function(client) - if client.server_capabilities.documentFormattingProvider then - vim.cmd "autocmd BufWritePre lua vim.lsp.buf.format()" - end - end, -}