Eric Bower
·
2025-04-02
plugins.lua
1local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
2if not (vim.uv or vim.loop).fs_stat(lazypath) then
3 local lazyrepo = "https://github.com/folke/lazy.nvim.git"
4 local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
5 if vim.v.shell_error ~= 0 then
6 vim.api.nvim_echo({
7 { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
8 { out, "WarningMsg" },
9 { "\nPress any key to exit..." },
10 }, true, {})
11 vim.fn.getchar()
12 os.exit(1)
13 end
14end
15vim.opt.rtp:prepend(lazypath)
16
17function setup_treesitter()
18 require'nvim-treesitter.configs'.setup {
19 ensure_installed = {
20 "bash",
21 "c",
22 "cmake",
23 "dockerfile",
24 "fish",
25 "git_config",
26 "git_rebase",
27 "gitattributes",
28 "gitcommit",
29 "gitignore",
30 "glimmer",
31 "go",
32 "gomod",
33 "gosum",
34 "html",
35 "javascript",
36 "jq",
37 "json",
38 "json5",
39 "lua",
40 "make",
41 "markdown",
42 "nix",
43 "python",
44 "query",
45 "r",
46 "ruby",
47 "rust",
48 "sql",
49 "terraform",
50 "toml",
51 "tsx",
52 "typescript",
53 "typst",
54 "vim",
55 "vimdoc",
56 "yaml",
57 "zig",
58 },
59 highlight = {
60 enable = true,
61 },
62 indent = {
63 enable = true
64 }
65 }
66end
67
68function setup_comp()
69 local cmp = require'cmp'
70 cmp.setup({
71 snippet = {
72 expand = function(args)
73 vim.fn["vsnip#anonymous"](args.body)
74 end,
75 },
76 mapping = {
77 ['<C-p>'] = cmp.mapping.select_prev_item(),
78 ['<C-n>'] = cmp.mapping.select_next_item(),
79 ['<Tab>'] = function(fallback)
80 if cmp.visible() then
81 cmp.select_next_item()
82 else
83 fallback()
84 end
85 end,
86 ['<S-Tab>'] = function(fallback)
87 if cmp.visible() then
88 cmp.select_prev_item()
89 else
90 fallback()
91 end
92 end,
93 ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
94 ['<CR>'] = cmp.mapping.confirm({ select = true }),
95 },
96 sources = {
97 { name = 'nvim_lsp' },
98 },
99 })
100end
101
102function setup_lsp()
103 local opts = { noremap=true, silent=true }
104 vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
105 vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
106 -- Use an on_attach function to only map the following keys
107 -- after the language server attaches to the current buffer
108 local on_attach = function(client, bufnr)
109 local bufopts = { noremap=true, silent=true, buffer=bufnr }
110
111 --Enable completion triggered by <c-x><c-o>
112 vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
113
114 -- Mappings.
115
116 -- See `:help vim.lsp.*` for documentation on any of the below functions
117 vim.keymap.set('n', '<leader>d', vim.lsp.buf.definition, bufopts)
118 vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
119 vim.keymap.set('n', '<leader>h', vim.lsp.buf.hover, bufopts)
120 vim.keymap.set('n', '<leader>r', vim.lsp.buf.references, bufopts)
121 vim.keymap.set('n', '<leader>k', vim.lsp.buf.signature_help, bufopts)
122 vim.keymap.set('n', '<leader>i', vim.lsp.buf.implementation, bufopts)
123 end
124
125 local nvim_lsp = require('lspconfig')
126 local capabilities = vim.lsp.protocol.make_client_capabilities()
127 capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
128 capabilities.textDocument.foldingRange = {
129 dynamicRegistration = false,
130 lineFoldingOnly = true
131 }
132
133 function handler(server_name)
134 local opts = {
135 capabilities = capabilities,
136 on_attach = on_attach,
137 }
138 if server_name == "denols" then
139 opts.root_dir = nvim_lsp.util.root_pattern("deno.json", "deno.jsonc")
140 elseif server_name == "ts_ls" then
141 opts.root_dir = nvim_lsp.util.root_pattern("package.json")
142 -- https://github.com/neovim/nvim-lspconfig/issues/2507#issuecomment-1471438640
143 opts.single_file_support = false
144 end
145 nvim_lsp[server_name].setup(opts)
146 end
147
148 -- npm i -g vscode-langservers-extracted
149 handler("cssls")
150 handler("denols")
151 handler("gopls")
152 handler("html")
153 handler("jsonls")
154 handler("pyright")
155 -- npm i -g typescript typescript-language-server
156 handler("ts_ls")
157 handler("zls")
158end
159
160require("lazy").setup({
161 rocks = {
162 enabled = false,
163 },
164 spec = {
165 {
166 'neovim/nvim-lspconfig',
167 config = setup_lsp,
168 },
169 {
170 'nvim-treesitter/nvim-treesitter',
171 build = ':TSUpdate',
172 config = setup_treesitter
173 },
174 {
175 "hrsh7th/nvim-cmp",
176 dependencies = {
177 "hrsh7th/cmp-buffer",
178 "hrsh7th/cmp-vsnip",
179 "hrsh7th/vim-vsnip"
180 },
181 config = setup_comp,
182 },
183 "hrsh7th/cmp-nvim-lsp",
184 {
185 'lukas-reineke/indent-blankline.nvim',
186 config = function()
187 require("ibl").setup({
188 scope = { enabled = false },
189 })
190 end
191 },
192 {
193 'ruifm/gitlinker.nvim',
194 dependencies = 'nvim-lua/plenary.nvim',
195 config = function()
196 require"gitlinker".setup()
197 end,
198 },
199 {
200 "christoomey/vim-tmux-navigator",
201 cmd = {
202 "TmuxNavigateLeft",
203 "TmuxNavigateDown",
204 "TmuxNavigateUp",
205 "TmuxNavigateRight",
206 "TmuxNavigatePrevious",
207 "TmuxNavigatorProcessList",
208 },
209 keys = {
210 { "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
211 { "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
212 { "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
213 { "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
214 { "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
215 },
216 },
217 {
218 'Mofiqul/dracula.nvim',
219 lazy = false,
220 priority = 1000,
221 config = function()
222 require('dracula').setup({})
223 vim.cmd[[colorscheme dracula]]
224 end
225 },
226 {
227 "karb94/neoscroll.nvim",
228 config = function()
229 require('neoscroll').setup({})
230 end
231 },
232 {
233 "ibhagwan/fzf-lua",
234 config = function()
235 local fzf = require('fzf-lua')
236 local fzfFiles = function()
237 fzf.files({
238 winopts = {
239 preview = { hidden = "hidden" },
240 },
241 })
242 end
243 vim.keymap.set("n", "<leader>s", fzfFiles, { desc = "Fzf Files", noremap=true, silent=true })
244 vim.keymap.set("n", "<leader>f", fzf.buffers, { desc = "Fzf Buffers", noremap=true, silent=true })
245 vim.keymap.set("n", "<leader>S", fzf.live_grep, { desc = "Fzf Grep", noremap=true, silent=true })
246 fzf.setup({'max-perf'})
247 end
248 },
249 {
250 "nvim-treesitter/nvim-treesitter-context",
251 config = function()
252 require'treesitter-context'.setup({
253 max_lines = 1,
254 })
255 end,
256 },
257 {
258 "chentoast/marks.nvim",
259 config = function()
260 require'marks'.setup({})
261 end,
262 },
263 {
264 'nvim-lualine/lualine.nvim',
265 config = function()
266 require'lualine'.setup({})
267 end
268 },
269 -- vim plugins
270 'rhysd/git-messenger.vim'
271 },
272})