aboutsummaryrefslogtreecommitdiff
path: root/config/nvim/lua/plugins.lua
blob: 6e33f5bdc2bf6a156d70605ed4531c12be1973f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
	vim.fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
	vim.cmd([[packadd packer.nvim]])
end

local treesitter_formaters = {
	"c",
	"lua",
	"kconfig",
	"make",
	"markdown",
	"markdown_inline",
	"meson",
	"ninja",
	"ini",
	"gitcommit",
	"git_rebase",
	"git_config",
	"nix",
	"python",
	"toml",
	"vim",
	"vimdoc",
	"yaml",
}

require("packer").startup(function(use)
	use("wbthomason/packer.nvim")
	-- Visual ------------------------------------------------------------------
	use("shaunsingh/nord.nvim")
	use("MunifTanjim/nui.nvim")
	use({
		"nvim-treesitter/nvim-treesitter",
		run = ":TSUpdate",
		config = function()
			require("nvim-treesitter.configs").setup({
				ensure_installed = treesitter_formaters,
				highlight = {
					enable = true,
					additional_vim_regex_highlighting = false,
				},
			})
		end,
	})
	use({
		"lukas-reineke/indent-blankline.nvim",
		config = function()
			local highlight = { "CursorColumn", "Whitespace" }
			require("ibl").setup({
				indent = { highlight = highlight, char = "" },
				whitespace = {
					highlight = highlight,
					remove_blankline_trail = false,
				},
				scope = { enabled = false },
			})
		end,
	})
	use("itchyny/lightline.vim")
	use("josa42/nvim-lightline-lsp")
	use({
		"nvim-telescope/telescope.nvim",
		config = function()
			require("mytelescope")
		end,
	})
	-- Git ---------------------------------------------------------------------
	use("tpope/vim-fugitive")
	use("airblade/vim-gitgutter")
	use({
		"harrisoncramer/gitlab.nvim",
		requires = {
			"MunifTanjim/nui.nvim",
			"nvim-lua/plenary.nvim",
			"sindrets/diffview.nvim",
			"stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
			"nvim-tree/nvim-web-devicons", -- Recommended but not required. Icons in discussion tree.
		},
		run = function()
			require("gitlab.server").build(true)
		end,
		config = function()
			require("diffview").setup()
			require("gitlab").setup()
		end,
	})
	-- Programming -------------------------------------------------------------
	use("neovim/nvim-lspconfig")
	use("p00f/clangd_extensions.nvim")
	use({
		"mfussenegger/nvim-lint",
		config = function()
			local lint = require("lint")
			lint.linters_by_ft = {
				c = { "cppcheck", "flawfinder", "editorconfig-checker" },
				lua = { "selene", "editorconfig-checker" },
				markdown = { "vale" },
				nix = { "statix", "deadnix", "nix", "editorconfig-checker" },
				python = { "pylint", "mypy", "pydocstyle", "editorconfig-checker" },
				sh = { "shellcheck", "editorconfig-checker" },
			}
			lint.linters.deadnix = {
				cmd = "deadnix",
				stdin = false,
				args = { "--output-format", "json" },
				stream = "stdout",
				parser = function(output)
					local lines = vim.fn.split(output, "\n")
					local diagnostics = {}
					for _, line in ipairs(lines) do
						local ok, decoded = pcall(vim.json.decode, line)
						if ok and decoded.file ~= nil then
							for _, result in ipairs(decoded.results) do
								table.insert(diagnostics, {
									lnum = result.line,
									end_lnum = result.line,
									col = result.column,
									end_col = result.endColumn,
									severity = vim.diagnostic.severity.HINT,
									source = "deadnix",
									message = result.message,
								})
							end
						end
					end
					return diagnostics
				end,
			}
			vim.api.nvim_create_autocmd({ "BufReadPost", "BufWrite", "InsertLeave" }, {
				callback = function()
					lint.try_lint()
				end,
			})
		end,
	})
	use({
		"stevearc/conform.nvim",
		config = function()
			require("conform").setup({
				formatters_by_ft = {
					c = { "clang-format", "trim_newlines", "twim_whitespace" },
					json = { "jq", "trim_newlines", "twim_whitespace" },
					lua = { "stylua", "trim_newlines", "twim_whitespace" },
					nix = { "alejandra", "trim_newlines", "twim_whitespace" },
					python = { "isort", "black", "trim_newlines", "twim_whitespace" },
					sh = { "shfmt", "trim_newlines", "twim_whitespace" },
					yaml = { "yq", "trim_newlines", "twim_whitespace" },
				},
			})
		end,
	})
	use("SirVer/ultisnips")
	use("honza/vim-snippets")
	use("craigemery/vim-autotag")
	use("scrooloose/nerdcommenter")
	-- Movement, format and others ---------------------------------------------
	use("tpope/vim-surround")
	use("tpope/vim-repeat")
	use("dhruvasagar/vim-table-mode")
	-- Filetypes ---------------------------------------------------------------
	use("tmhedberg/SimpylFold")
	use("LnL7/vim-nix")
	use("kaarmu/typst.vim")
	use("aliou/bats.vim")

	-- LSP ---------------------------------------------------------------------
	local lspconfig = require("lspconfig")
	lspconfig.clangd.setup({})
	lspconfig.nil_ls.setup({})
	lspconfig.pylsp.setup({})
	lspconfig.bashls.setup({})
end)