summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/getchoo/plugins
diff options
context:
space:
mode:
authorseth <[email protected]>2023-04-02 21:14:36 -0400
committerseth <[email protected]>2023-04-02 21:14:36 -0400
commit8a8be409c0f0d911eb19969c05e7f4a171a63767 (patch)
tree3dcdd90daed9ef83527093396d185a7bfda9dbd5 /.config/nvim/lua/getchoo/plugins
parentd421be1222d6744c0d738e5fbf96ee6daafd61b2 (diff)
copy refactor from flake for neovim config
Diffstat (limited to '.config/nvim/lua/getchoo/plugins')
-rw-r--r--.config/nvim/lua/getchoo/plugins/general.lua57
-rw-r--r--.config/nvim/lua/getchoo/plugins/init.lua96
-rw-r--r--.config/nvim/lua/getchoo/plugins/lsp.lua200
3 files changed, 353 insertions, 0 deletions
diff --git a/.config/nvim/lua/getchoo/plugins/general.lua b/.config/nvim/lua/getchoo/plugins/general.lua
new file mode 100644
index 0000000..93cd720
--- /dev/null
+++ b/.config/nvim/lua/getchoo/plugins/general.lua
@@ -0,0 +1,57 @@
+--
+-- configuration for general plugins
+--
+
+---- autopairs
+require("nvim-autopairs").setup({
+ disable_filetype = { "TeleScopePrompt" },
+})
+
+---- catppuccin
+local compile_path = vim.fn.stdpath("cache") .. "/catppuccin-nvim"
+vim.fn.mkdir(compile_path, "p")
+vim.opt.runtimepath:append(compile_path)
+
+require("catppuccin").setup({
+ compile_path = compile_path,
+ flavour = "mocha", -- mocha, macchiato, frappe, latte
+ integrations = {
+ barbar = true,
+ cmp = true,
+ gitsigns = true,
+ leap = true,
+ native_lsp = {
+ enabled = true,
+ },
+ nvimtree = true,
+ treesitter_context = true,
+ treesitter = true,
+ telescope = true,
+ lsp_trouble = true,
+ },
+ no_italic = true,
+})
+vim.api.nvim_command("colorscheme catppuccin")
+
+---- bufferline
+require("bufferline").setup({
+ options = {
+ highlights = require("catppuccin.groups.integrations.bufferline").get(),
+ diagnostics = "nvim_lsp",
+ numbers = "ordinal",
+ },
+})
+
+---- leap
+require("leap").add_default_mappings()
+
+---- lualine
+require("lualine").setup({
+ options = {
+ theme = "catppuccin",
+ },
+ extensions = { "nvim-tree" },
+})
+
+---- nvim-tree
+require("nvim-tree").setup()
diff --git a/.config/nvim/lua/getchoo/plugins/init.lua b/.config/nvim/lua/getchoo/plugins/init.lua
new file mode 100644
index 0000000..b76f4c5
--- /dev/null
+++ b/.config/nvim/lua/getchoo/plugins/init.lua
@@ -0,0 +1,96 @@
+--
+-- plugin init for neovim
+--
+
+local fn = vim.fn
+local cmd = vim.cmd
+
+local packer_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
+
+if fn.empty(fn.glob(packer_path)) > 0 then
+ Packer_bootstrap = fn.system({
+ "git",
+ "clone",
+ "--depth",
+ "1",
+ "https://github.com/wbthomason/packer.nvim",
+ packer_path,
+ })
+ cmd("packadd packer.nvim")
+end
+
+require("packer").startup(function(use)
+ use("wbthomason/packer.nvim")
+
+ -- comsetic plugins
+ use({ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons" } })
+
+ use({
+ "catppuccin/nvim",
+ as = "catppuccin",
+ })
+
+ -- general use plugins
+ use({
+ "akinsho/bufferline.nvim",
+ requires = { "kyazdani42/nvim-web-devicons" },
+ })
+
+ use("ggandor/leap.nvim")
+ use("kyazdani42/nvim-tree.lua")
+ use("windwp/nvim-autopairs")
+
+ -- lsp plugins
+ if vim.g.use_lsp_plugins then
+ use("neovim/nvim-lspconfig")
+
+ use({
+ "jose-elias-alvarez/null-ls.nvim",
+ requires = { "nvim-lua/plenary.nvim" },
+ })
+
+ if vim.g.use_mason then
+ use("williamboman/mason.nvim")
+ use("williamboman/mason-lspconfig")
+ use("whoissethdaniel/mason-tool-installer.nvim")
+ end
+
+ use({
+ "nvim-treesitter/nvim-treesitter",
+ run = function()
+ require("nvim-treesitter.install").update({ with_sync = true })
+ end,
+ })
+
+ use("hrsh7th/nvim-cmp")
+ use("hrsh7th/cmp-nvim-lsp")
+ use("hrsh7th/cmp-buffer")
+ use("hrsh7th/cmp-path")
+ use("hrsh7th/cmp-vsnip")
+ use("hrsh7th/vim-vsnip")
+ use("L3MON4D3/LuaSnip")
+ use("saadparwaiz1/cmp_luasnip")
+
+ use({
+ "folke/trouble.nvim",
+ requires = { "kyazdani42/nvim-web-devicons" },
+ })
+ use({
+ "nvim-telescope/telescope.nvim",
+ requires = { "nvim-lua/plenary.nvim" },
+ })
+
+ use("lewis6991/gitsigns.nvim")
+ use("j-hui/fidget.nvim")
+ end
+
+ if Packer_bootstrap then
+ require("packer").sync()
+ end
+end)
+
+require("getchoo.plugins.general")
+
+if vim.g.use_lsp_plugins then
+ require("getchoo.plugins.lsp")
+end
diff --git a/.config/nvim/lua/getchoo/plugins/lsp.lua b/.config/nvim/lua/getchoo/plugins/lsp.lua
new file mode 100644
index 0000000..96dc950
--- /dev/null
+++ b/.config/nvim/lua/getchoo/plugins/lsp.lua
@@ -0,0 +1,200 @@
+--
+-- configuration for lsp plugins
+--
+
+---- cmp
+local cmp = require("cmp")
+local luasnip = require("luasnip")
+local mapping = cmp.mapping
+
+local has_words_before = function()
+ local line, col = unpack(vim.api.nvim_win_get_cursor(0))
+ return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
+end
+
+local feedkey = function(key, mode)
+ vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
+end
+local cmp_on_attach = function(_, bufnr)
+ vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
+end
+
+local capabilities = require("cmp_nvim_lsp").default_capabilities()
+capabilities.textDocument.completion.completionItem.snippetSupport = true
+
+require("cmp").setup({
+ snippet = {
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body)
+ luasnip.lsp_expand(args.body)
+ end,
+ },
+
+ mapping = mapping.preset.insert({
+ ["<Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif luasnip.expand_or_jumpable() then
+ luasnip.expand_or_jump()
+ elseif vim.fn["vsnip#available"](1) == 1 then
+ feedkey("<Plug>(vsnip-expand-or-jump)", "")
+ elseif has_words_before() then
+ cmp.complete()
+ else
+ fallback()
+ end
+ end, { "i", "s" }),
+ ["<S-Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ elseif luasnip.jumpable(-1) then
+ luasnip.jump(-1)
+ elseif vim.fn["vsnip#available"](-1) == 1 then
+ feedkey("<Plug>(vsnip-jump-prev)", "")
+ else
+ fallback()
+ end
+ end, { "i", "s" }),
+ }),
+
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "luasnip" },
+ { name = "vsnip" },
+ { name = "buffer" },
+ { name = "path" },
+ }),
+
+ capabilities = capabilities,
+
+ on_attach = cmp_on_attach,
+})
+
+---- fidget
+require("fidget").setup()
+
+---- gitsigns
+require("gitsigns").setup()
+
+---- lsp sources
+local null_ls = require("null-ls")
+local diagnostics = null_ls.builtins.diagnostics
+local formatting = null_ls.builtins.formatting
+
+local sources = {
+ lsp_servers = { "bashls", "clangd", "pyright", "rust_analyzer" },
+ null_ls = {
+ diagnostics.alex,
+ diagnostics.codespell,
+ diagnostics.deadnix,
+ diagnostics.pylint,
+ diagnostics.shellcheck,
+ diagnostics.statix,
+ formatting.alejandra,
+ formatting.codespell,
+ formatting.prettier,
+ formatting.rustfmt,
+ formatting.stylua,
+ formatting.yapf,
+ },
+ mason = {
+ "alex",
+ "codespell",
+ "pylint",
+ "prettier",
+ "shellcheck",
+ "stylua",
+ "yapf",
+ },
+}
+
+--- lsp config
+local all_config = {
+ capabilities = capabilities,
+ on_attach = cmp_on_attach,
+}
+
+local servers = {}
+for _, server in ipairs(sources.lsp_servers) do
+ servers[server] = all_config
+end
+
+servers["lua_ls"] = {
+ capabilities = capabilities,
+ on_attach = cmp_on_attach,
+ settings = {
+ Lua = {
+ runtime = {
+ version = "LuaJIT",
+ },
+ diagnostics = {
+ globals = { "vim" },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ },
+ },
+}
+
+for server, settings in pairs(servers) do
+ require("lspconfig")[server].setup(settings)
+end
+
+---- mason
+if vim.g.use_mason then
+ require("mason").setup()
+ require("mason-lspconfig").setup({
+ automatic_installation = true,
+ })
+ require("mason-lspconfig").setup_handlers({
+ function(server)
+ require("lspconfig")[server].setup(all_config)
+ end,
+ })
+ require("mason-tool-installer").setup({
+ ensure_installed = sources.mason,
+ })
+end
+
+---- null-ls
+-- auto-format
+local lsp_formatting = function(bufnr)
+ vim.lsp.buf.format({
+ filter = function(client)
+ return client.name == "null-ls"
+ end,
+ bufnr = bufnr,
+ })
+end
+
+local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
+local formatting_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()
+ lsp_formatting(bufnr)
+ end,
+ })
+ end
+end
+
+require("null-ls").setup({
+ on_attach = formatting_on_attach,
+ sources = sources.null_ls,
+})
+
+---- trouble
+require("trouble").setup()
+
+---- treesitter
+require("nvim-treesitter.configs").setup({
+ auto_install = true,
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = false,
+ },
+})