neovim conf based on kickstart.nvim
1return {
2 {
3 'nvimtools/none-ls.nvim',
4 dependencies = { 'mason.nvim' },
5 opts = function(_, opts)
6 local nls = require 'null-ls'
7 opts.root_dir = opts.root_dir or require('null-ls.utils').root_pattern('.null-ls-root', '.neoconf.json', 'Makefile', '.git')
8 opts.sources = vim.list_extend(opts.sources or {}, {
9 nls.builtins.formatting.fish_indent,
10 nls.builtins.diagnostics.fish,
11 nls.builtins.formatting.stylua,
12 nls.builtins.formatting.shfmt,
13 })
14 end,
15 },
16 {
17 'tpope/vim-dadbod',
18 },
19 {
20 'kristijanhusak/vim-dadbod-ui',
21 dependencies = {
22 { 'tpope/vim-dadbod', lazy = true },
23 { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true },
24 },
25 cmd = {
26 'DBUI',
27 'DBUIToggle',
28 'DBUIAddConnection',
29 'DBUIFindBuffer',
30 },
31 init = function()
32 -- Your DBUI configuration
33 vim.g.db_ui_use_nerd_fonts = 1
34 end,
35 },
36 {
37 'nvim-neotest/neotest',
38 dependencies = { 'nvim-neotest/nvim-nio', 'marilari88/neotest-vitest', 'mrcjkb/rustaceanvim' },
39 opts = {
40 -- Can be a list of adapters like what neotest expects,
41 -- or a list of adapter names,
42 -- or a table of adapter names, mapped to adapter configs.
43 -- The adapter will then be automatically loaded with the config.
44 adapters = {
45 ['neotest-vitest'] = {},
46 ['rustaceanvim.neotest'] = {},
47 },
48 -- Example for loading neotest-golang with a custom config
49 -- adapters = {
50 -- ["neotest-golang"] = {
51 -- go_test_args = { "-v", "-race", "-count=1", "-timeout=60s" },
52 -- dap_go_enabled = true,
53 -- },
54 -- },
55 status = { virtual_text = true },
56 output = { open_on_run = true },
57 quickfix = {
58 open = function() require('trouble').open { mode = 'quickfix', focus = false } end,
59 },
60 },
61 config = function(_, opts)
62 local neotest_ns = vim.api.nvim_create_namespace 'neotest'
63 vim.diagnostic.config({
64 virtual_text = {
65 format = function(diagnostic)
66 -- Replace newline and tab characters with space for more compact diagnostics
67 local message = diagnostic.message:gsub('\n', ' '):gsub('\t', ' '):gsub('%s+', ' '):gsub('^%s+', '')
68 return message
69 end,
70 },
71 }, neotest_ns)
72
73 opts.consumers = opts.consumers or {}
74 -- Refresh and auto close trouble after running tests
75 ---@type neotest.Consumer
76 opts.consumers.trouble = function(client)
77 client.listeners.results = function(adapter_id, results, partial)
78 if partial then return end
79 local tree = assert(client:get_position(nil, { adapter = adapter_id }))
80
81 local failed = 0
82 for pos_id, result in pairs(results) do
83 if result.status == 'failed' and tree:get_key(pos_id) then failed = failed + 1 end
84 end
85 vim.schedule(function()
86 local trouble = require 'trouble'
87 if trouble.is_open() then
88 trouble.refresh()
89 if failed == 0 then trouble.close() end
90 end
91 end)
92 return {}
93 end
94 end
95
96 if opts.adapters then
97 local adapters = {}
98 for name, config in pairs(opts.adapters or {}) do
99 if type(name) == 'number' then
100 if type(config) == 'string' then config = require(config) end
101 adapters[#adapters + 1] = config
102 elseif config ~= false then
103 local adapter = require(name)
104 if type(config) == 'table' and not vim.tbl_isempty(config) then
105 local meta = getmetatable(adapter)
106 if adapter.setup then
107 adapter.setup(config)
108 elseif adapter.adapter then
109 adapter.adapter(config)
110 adapter = adapter.adapter
111 elseif meta and meta.__call then
112 adapter = adapter(config)
113 else
114 error('Adapter ' .. name .. ' does not support setup')
115 end
116 end
117 adapters[#adapters + 1] = adapter
118 end
119 end
120 opts.adapters = adapters
121 end
122
123 require('neotest').setup(opts)
124 end,
125 keys = {
126 { '<leader>t', '', desc = '+test' },
127 { '<leader>ta', function() require('neotest').run.attach() end, desc = 'Attach to Test (Neotest)' },
128 { '<leader>tt', function() require('neotest').run.run(vim.fn.expand '%') end, desc = 'Run File (Neotest)' },
129 { '<leader>tT', function() require('neotest').run.run(vim.uv.cwd()) end, desc = 'Run All Test Files (Neotest)' },
130 { '<leader>tr', function() require('neotest').run.run() end, desc = 'Run Nearest (Neotest)' },
131 { '<leader>tl', function() require('neotest').run.run_last() end, desc = 'Run Last (Neotest)' },
132 { '<leader>ts', function() require('neotest').summary.toggle() end, desc = 'Toggle Summary (Neotest)' },
133 { '<leader>to', function() require('neotest').output.open { enter = true, auto_close = true } end, desc = 'Show Output (Neotest)' },
134 { '<leader>tO', function() require('neotest').output_panel.toggle() end, desc = 'Toggle Output Panel (Neotest)' },
135 { '<leader>tS', function() require('neotest').run.stop() end, desc = 'Stop (Neotest)' },
136 { '<leader>tw', function() require('neotest').watch.toggle(vim.fn.expand '%') end, desc = 'Toggle Watch (Neotest)' },
137 },
138 },
139 {
140 'mrcjkb/rustaceanvim',
141 ft = { 'rust' },
142 opts = {
143 server = {
144 on_attach = function(_, bufnr)
145 vim.keymap.set('n', '<leader>cR', function() vim.cmd.RustLsp 'codeAction' end, { desc = 'Code Action', buffer = bufnr })
146 vim.keymap.set('n', '<leader>dr', function() vim.cmd.RustLsp 'debuggables' end, { desc = 'Rust Debuggables', buffer = bufnr })
147 end,
148 default_settings = {
149 -- rust-analyzer language server configuration
150 ['rust-analyzer'] = {
151 cargo = {
152 allFeatures = true,
153 loadOutDirsFromCheck = true,
154 buildScripts = {
155 enable = true,
156 },
157 },
158 -- Add clippy lints for Rust if using rust-analyzer
159 checkOnSave = diagnostics == 'rust-analyzer',
160 -- Enable diagnostics if using rust-analyzer
161 diagnostics = {
162 enable = diagnostics == 'rust-analyzer',
163 },
164 procMacro = {
165 enable = true,
166 },
167 files = {
168 exclude = {
169 '.direnv',
170 '.git',
171 '.jj',
172 '.github',
173 '.gitlab',
174 'bin',
175 'node_modules',
176 'target',
177 'venv',
178 '.venv',
179 },
180 -- Avoid Roots Scanned hanging, see https://github.com/rust-lang/rust-analyzer/issues/12613#issuecomment-2096386344
181 watcher = 'client',
182 },
183 },
184 },
185 },
186 },
187 config = function(_, opts)
188 local codelldb = vim.fn.exepath 'codelldb'
189 local codelldb_lib_ext = io.popen('uname'):read '*l' == 'Linux' and '.so' or '.dylib'
190 local library_path = vim.fn.expand('$MASON/opt/lldb/lib/liblldb' .. codelldb_lib_ext)
191 opts.dap = {
192 adapter = require('rustaceanvim.config').get_codelldb_adapter(codelldb, library_path),
193 }
194 vim.g.rustaceanvim = vim.tbl_deep_extend('keep', vim.g.rustaceanvim or {}, opts or {})
195 end,
196 },
197}