summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorseth <[email protected]>2024-10-29 22:37:49 -0400
committerGitHub <[email protected]>2024-10-30 02:37:49 +0000
commit310fdf8de53d98ddd3a56936c131186e25814f0f (patch)
treef4265ab11de2262bacb2498cdc4661420a2df278 /lua
parent7ed0a2b87684eb32009944bd9eb8d7eaa9af0462 (diff)
use lz.n (#69)
* remove bufferline & some cmp sources * factor things out of after/ folder This is bad practice or something * make sure ftdetect plugins aren't loaded multiple times * use lz.n * mini.pairs -> mini.surround * flake: cleanup checks * ftplugin: enforce spaces in nix files
Diffstat (limited to 'lua')
-rw-r--r--lua/getchoo/init.lua4
-rw-r--r--lua/getchoo/plugins/catppuccin.lua36
-rw-r--r--lua/getchoo/plugins/cmp.lua42
-rw-r--r--lua/getchoo/plugins/crates.lua9
-rw-r--r--lua/getchoo/plugins/fidget.lua10
-rw-r--r--lua/getchoo/plugins/flash.lua11
-rw-r--r--lua/getchoo/plugins/gitsigns.lua9
-rw-r--r--lua/getchoo/plugins/glow.lua9
-rw-r--r--lua/getchoo/plugins/ibl.lua27
-rw-r--r--lua/getchoo/plugins/lint.lua22
-rw-r--r--lua/getchoo/plugins/lsp.lua157
-rw-r--r--lua/getchoo/plugins/lualine.lua14
-rw-r--r--lua/getchoo/plugins/mini.lua45
-rw-r--r--lua/getchoo/plugins/telescope.lua13
-rw-r--r--lua/getchoo/plugins/treesitter.lua12
-rw-r--r--lua/getchoo/plugins/trouble.lua12
-rw-r--r--lua/getchoo/utils.lua10
17 files changed, 442 insertions, 0 deletions
diff --git a/lua/getchoo/init.lua b/lua/getchoo/init.lua
index 2f72940..021333c 100644
--- a/lua/getchoo/init.lua
+++ b/lua/getchoo/init.lua
@@ -14,3 +14,7 @@ opt.wrap = true
-- ui
opt.mouse = "a"
opt.showmode = false -- status line does this
+
+require("lz.n").load("getchoo/plugins")
+
+vim.cmd.colorscheme("catppuccin")
diff --git a/lua/getchoo/plugins/catppuccin.lua b/lua/getchoo/plugins/catppuccin.lua
new file mode 100644
index 0000000..18daf1f
--- /dev/null
+++ b/lua/getchoo/plugins/catppuccin.lua
@@ -0,0 +1,36 @@
+local compile_path = vim.fn.stdpath("cache") .. "/catppuccin-nvim"
+
+return {
+ {
+ "catppuccin-nvim",
+ colorscheme = "catppuccin",
+ before = function()
+ vim.fn.mkdir(compile_path, "p")
+ vim.opt.runtimepath:append(compile_path)
+ end,
+ after = function()
+ require("catppuccin").setup({
+ compile_path = compile_path,
+ flavour = "mocha",
+ integrations = {
+ cmp = true,
+ flash = true,
+ gitsigns = true,
+ indent_blankline = {
+ enabled = true,
+ },
+ lsp_trouble = true,
+ native_lsp = {
+ enabled = true,
+ },
+ neotree = true,
+ treesitter = true,
+ telescope = true,
+ which_key = true,
+ },
+
+ no_italic = true,
+ })
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/cmp.lua b/lua/getchoo/plugins/cmp.lua
new file mode 100644
index 0000000..19f9150
--- /dev/null
+++ b/lua/getchoo/plugins/cmp.lua
@@ -0,0 +1,42 @@
+return {
+ {
+ "nvim-cmp",
+ lazy = false,
+ after = function()
+ local cmp = require("cmp")
+
+ cmp.setup({
+ completion = {
+ compleopt = "menu,menuone,insert",
+ },
+
+ mapping = {
+ ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-b>"] = cmp.mapping.scroll_docs(-4),
+ ["<C-f>"] = cmp.mapping.scroll_docs(4),
+ ["<C-Space>"] = cmp.mapping.complete(),
+ ["<C-e>"] = cmp.mapping.abort(),
+ ["<CR>"] = cmp.mapping({
+ i = function(fallback)
+ if cmp.visible() and cmp.get_active_entry() then
+ cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
+ else
+ fallback()
+ end
+ end,
+
+ s = cmp.mapping.confirm({ select = true }),
+ c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
+ }),
+ },
+
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "async_path" },
+ { name = "buffer" },
+ }),
+ })
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/crates.lua b/lua/getchoo/plugins/crates.lua
new file mode 100644
index 0000000..62476c4
--- /dev/null
+++ b/lua/getchoo/plugins/crates.lua
@@ -0,0 +1,9 @@
+return {
+ {
+ "crates.nvim",
+ event = "BufReadPost Cargo.toml",
+ after = function()
+ require("crates").setup()
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/fidget.lua b/lua/getchoo/plugins/fidget.lua
new file mode 100644
index 0000000..11a1a4d
--- /dev/null
+++ b/lua/getchoo/plugins/fidget.lua
@@ -0,0 +1,10 @@
+return {
+ {
+ "fidget.nvim",
+ -- https://github.com/LazyVim/LazyVim/blob/cb40a09538dc0c417a7ffbbacdbdec90be4a792c/lua/lazyvim/util/plugin.lua#L9
+ event = require("getchoo.utils").lazy_file,
+ after = function()
+ require("fidget").setup()
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/flash.lua b/lua/getchoo/plugins/flash.lua
new file mode 100644
index 0000000..521cbcb
--- /dev/null
+++ b/lua/getchoo/plugins/flash.lua
@@ -0,0 +1,11 @@
+return {
+ {
+ "flash.nvim",
+ event = "DeferredUIEnter",
+ keys = {
+ {
+ "f", function() require("flash").jump() end, mode = { "n", "o", "x" }
+ }
+ },
+ }
+}
diff --git a/lua/getchoo/plugins/gitsigns.lua b/lua/getchoo/plugins/gitsigns.lua
new file mode 100644
index 0000000..f63e5ce
--- /dev/null
+++ b/lua/getchoo/plugins/gitsigns.lua
@@ -0,0 +1,9 @@
+return {
+ {
+ "gitsigns.nvim",
+ event = require("getchoo.utils").lazy_file,
+ after = function()
+ require("gitsigns").setup()
+ end,
+ }
+}
diff --git a/lua/getchoo/plugins/glow.lua b/lua/getchoo/plugins/glow.lua
new file mode 100644
index 0000000..5758898
--- /dev/null
+++ b/lua/getchoo/plugins/glow.lua
@@ -0,0 +1,9 @@
+return {
+ {
+ "glow.nvim",
+ ft = "markdown",
+ after = function()
+ require("glow").setup()
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/ibl.lua b/lua/getchoo/plugins/ibl.lua
new file mode 100644
index 0000000..ae4481f
--- /dev/null
+++ b/lua/getchoo/plugins/ibl.lua
@@ -0,0 +1,27 @@
+return {
+ {
+ "indent-blankline.nvim",
+ event = require("getchoo.utils").lazy_file,
+ after = function()
+ require("ibl").setup({
+ exclude = {
+ filetypes = {
+ "help",
+ "Trouble",
+ "toggleterm",
+ },
+ },
+
+ indent = {
+ char = "│",
+ tab_char = "│",
+ },
+
+ scope = {
+ -- Let mini.nvim handle this
+ enabled = false,
+ },
+ })
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/lint.lua b/lua/getchoo/plugins/lint.lua
new file mode 100644
index 0000000..3cebc5c
--- /dev/null
+++ b/lua/getchoo/plugins/lint.lua
@@ -0,0 +1,22 @@
+return {
+ "nvim-lint",
+ event = require("getchoo.utils").lazy_file,
+ before = function()
+ vim.api.nvim_create_autocmd({ "BufWritePost" }, {
+ callback = function()
+ -- Run linters declared in linters_by_ft
+ require("lint").try_lint()
+
+ -- Run these linters regardless of filetype
+ require("lint").try_lint("alex")
+ end,
+ })
+ end,
+ after = function()
+ require("lint").linters_by_ft = {
+ githubaction = { "actionlint" },
+ lua = { "selene" },
+ nix = { "statix" },
+ }
+ end
+}
diff --git a/lua/getchoo/plugins/lsp.lua b/lua/getchoo/plugins/lsp.lua
new file mode 100644
index 0000000..2b2da52
--- /dev/null
+++ b/lua/getchoo/plugins/lsp.lua
@@ -0,0 +1,157 @@
+local lsp_servers = {
+ astro = {
+ binary = "astro-ls",
+ },
+
+ bashls = {
+ binary = "bash-language-server",
+ },
+
+ cssls = {
+ binary = "vscode-css-language-server",
+ },
+
+ clangd = {},
+
+ denols = {
+ binary = "deno",
+ },
+
+ dprint = {},
+
+ eslint = {
+ binary = "vscode-eslint-language-server",
+ },
+
+ html = {
+ binary = "vscode-html-language-server",
+ },
+
+ jsonls = {
+ binary = "vscode-json-language-server",
+ },
+
+ -- TODO: I WANT STYLUA BACK!!
+ lua_ls = {
+ binary = "lua-language-server",
+ extraOptions = {
+ settings = {
+ Lua = {
+ runtime = { version = "LuaJIT" },
+ diagnostics = { globals = "vim" },
+ workspace = { checkThirdPaty = false, library = { vim.env.VIMRUNTIME } },
+ },
+ },
+ },
+ },
+
+ nil_ls = {
+ binary = "nil",
+ extraOptions = {
+ settings = {
+ ["nil"] = {
+ formatting = { command = { "nixfmt" } },
+ },
+ },
+ },
+ },
+
+ nim_langserver = {
+ binary = "nimlangserver",
+ },
+
+ pyright = {
+ extraOptions = {
+ settings = {
+ -- ruff is used instead
+ pyright = { disableOrganizeImports = true },
+ python = { ignore = { "*" } },
+ },
+ },
+ },
+
+ ruff_lsp = {
+ binary = "ruff-lsp",
+ extraOptions = {
+ on_attach = function(client, _)
+ require("lsp-format").on_attach(client)
+ -- pyright should handle this
+ client.server_capabilities.hoverProvider = false
+ end,
+ },
+ },
+
+ rust_analyzer = {
+ binary = "rust-analyzer",
+ extraOptions = {
+ settings = {
+ ["rust-analyzer"] = {
+ check = { command = "clippy" },
+ },
+ },
+ },
+ },
+
+ ts_ls = {
+ binary = "typescript-language-server",
+ },
+
+ typos_lsp = {
+ binary = "typos-lsp",
+ },
+
+ typst_lsp = {
+ binary = "typst-lsp",
+ },
+}
+
+local caps = vim.tbl_deep_extend(
+ "force",
+ vim.lsp.protocol.make_client_capabilities(),
+ require("cmp_nvim_lsp").default_capabilities(),
+ -- for nil_ls
+ { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } }
+)
+
+local setup = {
+ on_attach = function(client, _)
+ require("lsp-format").on_attach(client)
+ end,
+
+ capabilities = caps,
+}
+
+
+return {
+ {
+ "lspformat.nvim",
+ command = "FormatToggle",
+ keys = { { "<leader>z", "<cmd>FormatToggle<cr>" } },
+ after = function()
+ require("lsp-format").setup()
+ end
+ },
+ {
+ "nvim-lspconfig",
+ event = require("getchoo.utils").lazy_file,
+ keys = {
+ { "<leader>e", vim.diagnostic.open_float },
+ { "[d", vim.diagnostic.goto_prev },
+ { "]d", vim.diagnostic.goto_next },
+ { "<leader>u", vim.diagnostic.setloclist },
+ { "<leader>ca", vim.lsp.buf.code_action }
+ },
+ after = function()
+ local lspconfig = require("lspconfig")
+
+ for server, config in pairs(lsp_servers) do
+ local binary = config.binary or server
+ local options = (config.extraOptions == nil) and setup or vim.tbl_extend("keep", config.extraOptions, setup)
+
+ if vim.fn.executable(binary) == 1 then
+ lspconfig[server].setup(options)
+ end
+ end
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/lualine.lua b/lua/getchoo/plugins/lualine.lua
new file mode 100644
index 0000000..e5eb8a1
--- /dev/null
+++ b/lua/getchoo/plugins/lualine.lua
@@ -0,0 +1,14 @@
+return {
+ {
+ "lualine.nvim",
+ event = "DeferredUIEnter",
+ after = function()
+ require("lualine").setup({
+ options = {
+ theme = "catppuccin",
+ },
+ extensions = { "trouble" },
+ })
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/mini.lua b/lua/getchoo/plugins/mini.lua
new file mode 100644
index 0000000..263cc77
--- /dev/null
+++ b/lua/getchoo/plugins/mini.lua
@@ -0,0 +1,45 @@
+return {
+ {
+ "mini.nvim",
+ event = "DeferredUIEnter",
+ keys = {
+ { "<leader>t", function()
+ local files = require("mini.files")
+ if not files.close() then
+ files.open()
+ end
+ end
+ }
+ },
+ before = function()
+ -- Disable indentscope in some files
+ vim.api.nvim_create_autocmd("FileType", {
+ pattern = {
+ "help",
+ "Trouble",
+ "toggleterm",
+ },
+
+ callback = function()
+ vim.b.miniindentscope_disable = true
+ end,
+ })
+ end,
+ after = function()
+ require("mini.files").setup()
+
+ local hipatterns = require("mini.hipatterns")
+ hipatterns.setup({
+ highlighters = {
+ hex_color = hipatterns.gen_highlighter.hex_color(),
+ },
+ })
+
+ require("mini.icons").setup()
+ require("mini.indentscope").setup({
+ options = { try_as_border = true },
+ })
+ require("mini.surround").setup()
+ end,
+ }
+}
diff --git a/lua/getchoo/plugins/telescope.lua b/lua/getchoo/plugins/telescope.lua
new file mode 100644
index 0000000..3887d4a
--- /dev/null
+++ b/lua/getchoo/plugins/telescope.lua
@@ -0,0 +1,13 @@
+return {
+ {
+ "telescope.nvim",
+ keys = {
+ { "<leader>fb", "<cmd>Telescope buffers<cr>" },
+ { "<leader>ff", "<cmd>Telescope find_files<cr>" },
+ { "<leader>fg", "<cmd>Telescope live_grep<cr>" }
+ },
+ after = function()
+ require("telescope").setup()
+ end
+ }
+}
diff --git a/lua/getchoo/plugins/treesitter.lua b/lua/getchoo/plugins/treesitter.lua
new file mode 100644
index 0000000..b6857eb
--- /dev/null
+++ b/lua/getchoo/plugins/treesitter.lua
@@ -0,0 +1,12 @@
+return {
+ "nvim-treesitter",
+ event = vim.tbl_extend("force", require("getchoo.utils").lazy_file, { "DeferredUIEnter" }),
+ after = function()
+ require("nvim-treesitter.configs").setup({
+ auto_install = false,
+
+ highlight = { enable = true },
+ indent = { enable = true },
+ })
+ end
+}
diff --git a/lua/getchoo/plugins/trouble.lua b/lua/getchoo/plugins/trouble.lua
new file mode 100644
index 0000000..2d3694b
--- /dev/null
+++ b/lua/getchoo/plugins/trouble.lua
@@ -0,0 +1,12 @@
+return {
+ {
+ "trouble.nvim",
+ cmd = "Trouble",
+ keys = {
+ { "<leader>p", "<cmd>Trouble diagnostics toggle<cr>" }
+ },
+ after = function()
+ require("trouble").setup()
+ end
+ }
+}
diff --git a/lua/getchoo/utils.lua b/lua/getchoo/utils.lua
new file mode 100644
index 0000000..efb38c2
--- /dev/null
+++ b/lua/getchoo/utils.lua
@@ -0,0 +1,10 @@
+local M = {}
+
+M.set_keymap = function(mode, key, vimcmd)
+ local opts = { noremap = true, silent = true }
+ vim.keymap.set(mode, key, vimcmd, opts)
+end
+
+M.lazy_file = { "BufReadPost", "BufNewFile", "BufWritePre" }
+
+return M