Skip to content

Commit fad598c

Browse files
authored
feat: simplify plugin and lualine configuration (#21)
Signed-off-by: Gamunu Balagalla <gamunu@fastcode.io>
1 parent e479511 commit fad598c

23 files changed

Lines changed: 958 additions & 646 deletions

README.md

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ Distribution Alternatives:
2424
> [Backup](#FAQ) your previous configuration (if any exists)
2525
2626
Requirements:
27-
* Make sure to review the readmes of the plugins if you are experiencing errors. In particular:
28-
* [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers.
29-
* See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native`
27+
* Make sure to review the readmes of the plugins if you are experiencing errors.
28+
* [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for `fzf-lua` live grep.
3029

3130
Neovim's configurations are located under the following paths, depending on your OS:
3231

@@ -68,10 +67,9 @@ nvim --headless "+Lazy! sync" +qa
6867

6968
* Inside of your copy, feel free to modify any file you like! It's your copy!
7069
* Feel free to change any of the default options in `init.lua` to better suit your needs.
71-
* For adding plugins, there are 3 primary options:
72-
* Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` (uncomment the line importing the `custom/plugins` directory in the `init.lua` file to enable this)
73-
* Modify `init.lua` with additional plugins.
74-
* Include the `lua/coldboot/plugins/*` files in your configuration.
70+
* For adding plugins, there are 2 primary options:
71+
* Add new configuration in `lua/custom/plugins/*` files (if you enable that import)
72+
* Edit the single plugin spec entrypoint: `lua/coldboot/plugins/init.lua`
7573

7674
You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration.
7775

@@ -151,14 +149,5 @@ Each PR, especially those which increase the line count, should have a descripti
151149

152150
### Windows Installation
153151

154-
Installation may require installing build tools, and updating the run command for `telescope-fzf-native`
155-
156-
See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation)
157-
158-
This requires:
159-
160-
- Install CMake, and the Microsoft C++ Build Tools on Windows
161-
162-
```lua
163-
{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
164-
```
152+
Some plugins may require build tools (e.g. CMake) on Windows.
153+
If you run into install/build errors, check the plugin's README and ensure you have the required toolchain installed.

init.lua

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ vim.opt.rtp:prepend(lazypath)
8484
-- You can also configure plugins after the setup call,
8585
-- as they will be available in your neovim runtime.
8686
require('lazy').setup({
87-
-- NOTE: First, some plugins that don't require any configuration
88-
-- import pure neovim plugins
8987
{
9088
import = 'coldboot.plugins',
9189
cond = function()
@@ -98,13 +96,6 @@ require('lazy').setup({
9896
return vim.g.vscode
9997
end,
10098
},
101-
102-
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
103-
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
104-
-- up-to-date with whatever is in the coldboot repo.
105-
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
106-
--
107-
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
10899
{ import = 'custom.plugins' },
109100
}, {})
110101

@@ -115,6 +106,8 @@ require('lazy').setup({
115106
-- Prepend mason bin to PATH
116107
vim.env.PATH = vim.fn.stdpath 'data' .. '/mason/bin' .. ':' .. vim.env.PATH
117108

109+
-- NOTE: LSP config is in lua/coldboot/config/lsp.lua
110+
118111
-- Set highlight on search
119112
vim.o.hlsearch = false
120113

@@ -149,6 +142,8 @@ vim.wo.signcolumn = 'yes'
149142
-- Decrease update time
150143
vim.o.updatetime = 250
151144
vim.o.timeoutlen = 300
145+
vim.o.ttimeout = true
146+
vim.o.ttimeoutlen = 100
152147

153148
-- Set completeopt to have a better completion experience
154149
vim.o.completeopt = 'menuone,noselect'
@@ -194,7 +189,7 @@ else
194189
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
195190
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
196191

197-
-- LSP configuration is now handled in the plugin files
192+
require 'coldboot.config'
198193

199194
-- document existing key chains
200195
require('which-key').add {
@@ -215,8 +210,6 @@ else
215210
{ '<leader>t', group = '[T]erminal' },
216211
{ '<leader>t_', hidden = true },
217212
}
218-
219-
-- LSP configuration is now handled in the plugin files
220213
end
221214
-- The line beneath this is called `modeline`. See `:help modeline`
222215
-- vim: ts=2 sts=2 sw=2 et

lua/coldboot/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Convenience entrypoint for configuration modules.
2+
-- Loaded from init.lua (non-vscode only).
3+
return require 'coldboot.config.init'

lua/coldboot/config/dap.lua

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
if vim.g.vscode then
2+
return
3+
end
4+
5+
local ok_dap, dap = pcall(require, 'dap')
6+
if not ok_dap then
7+
return
8+
end
9+
10+
local ok_ui, dapui = pcall(require, 'dapui')
11+
if ok_ui then
12+
dapui.setup()
13+
14+
dap.listeners.after.event_initialized['dapui_config'] = function()
15+
dapui.open()
16+
end
17+
dap.listeners.before.event_terminated['dapui_config'] = function()
18+
dapui.close()
19+
end
20+
dap.listeners.before.event_exited['dapui_config'] = function()
21+
dapui.close()
22+
end
23+
end
24+
25+
pcall(function()
26+
require('nvim-dap-virtual-text').setup()
27+
end)
28+
29+
pcall(function()
30+
require('dap-go').setup()
31+
end)
32+
33+
pcall(function()
34+
local js_debug_path = vim.fn.stdpath 'data' .. '/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js'
35+
36+
dap.adapters['pwa-node'] = {
37+
type = 'server',
38+
host = '127.0.0.1',
39+
port = '${port}',
40+
executable = {
41+
command = 'node',
42+
args = { js_debug_path, '${port}' },
43+
},
44+
}
45+
46+
dap.configurations.javascript = {
47+
{
48+
type = 'pwa-node',
49+
request = 'launch',
50+
name = 'Launch file',
51+
program = '${file}',
52+
cwd = '${workspaceFolder}',
53+
},
54+
{
55+
type = 'pwa-node',
56+
request = 'attach',
57+
name = 'Attach',
58+
processId = require('dap.utils').pick_process,
59+
cwd = '${workspaceFolder}',
60+
},
61+
}
62+
63+
dap.configurations.typescript = dap.configurations.javascript
64+
dap.configurations.javascriptreact = dap.configurations.javascript
65+
dap.configurations.typescriptreact = dap.configurations.javascript
66+
end)
67+
68+
local map = function(lhs, rhs, desc)
69+
vim.keymap.set('n', lhs, rhs, { desc = desc })
70+
end
71+
72+
map('<F5>', dap.continue, 'DAP continue')
73+
map('<F10>', dap.step_over, 'DAP step over')
74+
map('<F11>', dap.step_into, 'DAP step into')
75+
map('<F12>', dap.step_out, 'DAP step out')
76+
map('<leader>db', dap.toggle_breakpoint, 'DAP toggle breakpoint')
77+
map('<leader>dB', function()
78+
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
79+
end, 'DAP conditional breakpoint')
80+
map('<leader>dr', dap.repl.open, 'DAP open REPL')
81+
map('<leader>dl', dap.run_last, 'DAP run last')
82+
83+
if ok_ui then
84+
map('<leader>du', dapui.toggle, 'DAP UI toggle')
85+
end
86+
87+
map('<leader>dt', dap.terminate, 'DAP terminate')

lua/coldboot/config/format.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
local settings = require 'coldboot.settings'
2+
3+
if vim.g.vscode then
4+
return
5+
end
6+
7+
local ok, conform = pcall(require, 'conform')
8+
if not ok then
9+
return
10+
end
11+
12+
conform.setup {
13+
format_on_save = settings.format.format_on_save,
14+
formatters_by_ft = settings.format.formatters_by_ft,
15+
}
16+
17+
vim.api.nvim_create_user_command('Format', function(args)
18+
conform.format {
19+
async = false,
20+
lsp_format = 'fallback',
21+
timeout_ms = settings.format.format_on_save.timeout_ms,
22+
range = args.count > 0 and { start = { args.line1, 0 }, ['end'] = { args.line2, 0 } } or nil,
23+
}
24+
end, { range = true, desc = 'Format current buffer (Conform/LSP)' })

lua/coldboot/config/init.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if vim.g.vscode then
2+
return
3+
end
4+
5+
require 'coldboot.config.ui'
6+
require 'coldboot.config.mason'
7+
require 'coldboot.config.lsp'
8+
require 'coldboot.config.lint'
9+
require 'coldboot.config.format'

lua/coldboot/config/lint.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
local settings = require 'coldboot.settings'
2+
3+
if vim.g.vscode then
4+
return
5+
end
6+
7+
local ok, lint = pcall(require, 'lint')
8+
if not ok then
9+
return
10+
end
11+
12+
lint.linters_by_ft = settings.lint.linters_by_ft
13+
14+
local group = vim.api.nvim_create_augroup('ColdbootLint', { clear = true })
15+
vim.api.nvim_create_autocmd(settings.lint.events, {
16+
group = group,
17+
callback = function()
18+
lint.try_lint()
19+
end,
20+
})
21+
22+
vim.api.nvim_create_user_command('Lint', function()
23+
lint.try_lint()
24+
end, { desc = 'Run configured linters' })

0 commit comments

Comments
 (0)