Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ You can also merge updates/changes from the repo back into your fork, to keep up
### Docs

* [Git in Neovim (Neogit + Diffview)](doc/git.md)
* [IDE setup (Coc.nvim + ALE)](doc/coc-ale.md)

#### Example: Adding an autopairs plugin

Expand Down
38 changes: 38 additions & 0 deletions coc-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"diagnostic.displayByAle": true,
"suggest.insertMode": "insert",
"inlayHint.display": true,
"inlayHint.enableParameter": true,
"typescript.inlayHints.parameterNames.enabled": "all",
"typescript.inlayHints.parameterTypes.enabled": true,
"typescript.inlayHints.variableTypes.enabled": true,
"typescript.inlayHints.propertyDeclarationTypes.enabled": true,
"typescript.inlayHints.functionLikeReturnTypes.enabled": true,
"typescript.inlayHints.enumMemberValues.enabled": true,
"javascript.inlayHints.parameterNames.enabled": "all",
"javascript.inlayHints.parameterTypes.enabled": true,
"javascript.inlayHints.variableTypes.enabled": true,
"javascript.inlayHints.propertyDeclarationTypes.enabled": true,
"javascript.inlayHints.functionLikeReturnTypes.enabled": true,
"javascript.inlayHints.enumMemberValues.enabled": true,
"rust-analyzer.inlayHints": {
"bindingModeHints": { "enable": true },
"chainingHints": { "enable": true },
"closingBraceHints": { "enable": true },
"closureReturnTypeHints": { "enable": "always" },
"lifetimeElisionHints": { "enable": "always", "useParameterNames": true },
"parameterHints": { "enable": true },
"typeHints": { "enable": true }
},
"go.goplsOptions": {
"hints": {
"assignVariableTypes": true,
"compositeLiteralFields": true,
"compositeLiteralTypes": true,
"constantValues": true,
"functionTypeParameters": true,
"parameterNames": true,
"rangeVariableTypes": true
}
}
}
59 changes: 59 additions & 0 deletions doc/coc-ale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# IDE setup (Coc.nvim + ALE)

This config uses:

- **coc.nvim** for language servers, completion, code actions, rename, etc.
- **ALE** for linting/fixing and displaying diagnostics (Coc sends diagnostics to ALE).

## Where things are configured

- Plugin + keymaps: `lua/coldboot/plugins/coc_ale.lua`
- Coc settings (inlay hints, insert/replace mode, etc): `coc-settings.json`

## Keymaps (kept from the previous LSP setup)

Navigation / actions:

- `gd` definition
- `gD` declaration
- `gI` implementation
- `gr` references
- `K` hover
- `<C-k>` signature help
- `<leader>rn` rename
- `<leader>ca` code action (normal/visual)
- `<leader>D` type definition
- `<leader>ds` document symbols (`:CocList outline`)
- `<leader>ws` workspace symbols (`:CocList -I symbols`)

Formatting:

- `<leader>f` format buffer (Coc format, falls back to `:ALEFix`)
- `:Format` same as above
- `:ColdbootFormatToggle` toggles ALE fix-on-save

## Completion (IntelliJ-like)

In insert mode:

- `<C-n>` / `<C-p>`: if completion menu is visible, move selection; otherwise trigger completion.
- `<CR>`: accept completion **without overwriting** text to the right of the caret (“insert”).
- `<Tab>`: accept completion and **overwrite** the word to the right of the caret (“replace”).

## Inlay hints

Inlay hints are enabled via `coc-settings.json`.

- Toggle for the current buffer: `:CocCommand document.toggleInlayHint`

## Useful commands

- `:CocInfo` show Coc status
- `:CocConfig` edit Coc settings
- `:ALEInfo` show ALE status
- `:Mason` install/update LSP binaries (this config auto-installs `gopls`, `rust-analyzer`, `pyright`)

## Notes on external tools

ALE fixers/linters call external binaries (e.g. `eslint`, `prettier`, `golangci-lint`, `rustfmt`, `black`, `ruff`).
Install them per project (recommended) or globally so ALE can run them.
74 changes: 0 additions & 74 deletions lua/coldboot/plugins/autoformat.lua

This file was deleted.

167 changes: 167 additions & 0 deletions lua/coldboot/plugins/coc_ale.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
return {
{
'neoclide/coc.nvim',
branch = 'release',
init = function()
vim.g.coc_global_extensions = {
'coc-tsserver',
'coc-eslint',
'coc-prettier',
'coc-json',
'coc-pyright',
'coc-go',
'coc-rust-analyzer',
}

local map = function(mode, lhs, rhs, desc, opts)
opts = opts or {}
opts.silent = opts.silent ~= false
opts.remap = opts.remap ~= false
opts.desc = desc
vim.keymap.set(mode, lhs, rhs, opts)
end

local term = function(keys)
return vim.api.nvim_replace_termcodes(keys, true, false, true)
end

local delete_keyword_suffix = function()
local line = vim.api.nvim_get_current_line()
local col = vim.fn.col '.'
local suffix_len = 0

local i = col
while i <= #line do
local ch = line:sub(i, i)
if ch:match '[%w_]' then
suffix_len = suffix_len + 1
i = i + 1
else
break
end
end

if suffix_len == 0 then
return ''
end

return string.rep(term '<Del>', suffix_len)
end

map('n', 'gd', '<Plug>(coc-definition)', 'Goto definition')
map('n', 'gD', '<Plug>(coc-declaration)', 'Goto declaration')
map('n', 'gI', '<Plug>(coc-implementation)', 'Goto implementation')
map('n', 'gr', '<Plug>(coc-references)', 'Goto references')
map('n', '<leader>rn', '<Plug>(coc-rename)', 'Rename')
map('n', '<leader>ca', '<Plug>(coc-codeaction)', 'Code action')
map('x', '<leader>ca', '<Plug>(coc-codeaction-selected)', 'Code action (selection)')
map('n', '<leader>D', '<Plug>(coc-type-definition)', 'Type definition')
map('n', '<leader>ds', '<cmd>CocList outline<cr>', 'Document symbols', { remap = false })
map('n', '<leader>ws', '<cmd>CocList -I symbols<cr>', 'Workspace symbols', { remap = false })

map('n', 'K', function()
if vim.fn.exists '*CocActionAsync' == 1 then
vim.fn.CocActionAsync 'doHover'
else
vim.cmd 'normal! K'
end
end, 'Hover')

map('n', '<C-k>', '<Plug>(coc-signature-help)', 'Signature help')

-- Completion: IntelliJ-like acceptance
-- - Enter: accept with "insert" behavior (doesn't overwrite suffix)
-- - Tab: accept with "replace" behavior (delete suffix, then confirm)
vim.keymap.set('i', '<CR>', [[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"]], {
silent = true,
expr = true,
})

vim.keymap.set('i', '<Tab>', function()
if vim.fn['coc#pum#visible']() == 1 then
return delete_keyword_suffix() .. vim.fn['coc#pum#confirm']()
end
return term '<Tab>'
end, { silent = true, expr = true })

vim.keymap.set('i', '<S-Tab>', function()
if vim.fn['coc#pum#visible']() == 1 then
return vim.fn['coc#pum#prev'](1)
end
return term '<S-Tab>'
end, { silent = true, expr = true })

vim.keymap.set('i', '<C-n>', function()
if vim.fn['coc#pum#visible']() == 1 then
return vim.fn['coc#pum#next'](1)
end
vim.fn['coc#refresh']()
return ''
end, { silent = true, expr = true })

vim.keymap.set('i', '<C-p>', function()
if vim.fn['coc#pum#visible']() == 1 then
return vim.fn['coc#pum#prev'](1)
end
vim.fn['coc#refresh']()
return ''
end, { silent = true, expr = true })

map('n', '<leader>f', function()
if vim.fn.exists '*CocActionAsync' == 1 then
vim.fn.CocActionAsync 'format'
return
end
if vim.fn.exists ':ALEFix' == 2 then
vim.cmd 'ALEFix'
end
end, 'Format buffer', { remap = false })

vim.api.nvim_create_user_command('Format', function()
if vim.fn.exists '*CocActionAsync' == 1 then
vim.fn.CocActionAsync 'format'
return
end
if vim.fn.exists ':ALEFix' == 2 then
vim.cmd 'ALEFix'
end
end, { desc = 'Format current buffer (Coc/ALE)' })
end,
},
{
'dense-analysis/ale',
init = function()
vim.g.ale_disable_lsp = 1
vim.g.ale_use_neovim_diagnostics_api = 1
vim.g.ale_completion_enabled = 0

vim.g.ale_fix_on_save = 1
vim.g.ale_fixers = {
go = { 'gofmt', 'goimports' },
javascript = { 'eslint', 'prettier' },
typescript = { 'eslint', 'prettier' },
javascriptreact = { 'eslint', 'prettier' },
typescriptreact = { 'eslint', 'prettier' },
rust = { 'rustfmt' },
python = { 'isort', 'black' },
}

vim.g.ale_linters = {
go = { 'golangci-lint' },
javascript = { 'eslint' },
typescript = { 'eslint' },
javascriptreact = { 'eslint' },
typescriptreact = { 'eslint' },
rust = { 'clippy' },
python = { 'ruff' },
}

local format_is_enabled = vim.g.ale_fix_on_save == 1
vim.api.nvim_create_user_command('ColdbootFormatToggle', function()
format_is_enabled = not format_is_enabled
vim.g.ale_fix_on_save = format_is_enabled and 1 or 0
print('Setting autoformatting to: ' .. tostring(format_is_enabled))
end, {})
end,
},
}
Loading
Loading