feat: convert to blink, major lsp changes, lualine
This commit is contained in:
parent
82102e5e29
commit
51ab444c0d
44 changed files with 1387 additions and 700 deletions
234
init.lua
234
init.lua
|
|
@ -1,18 +1,38 @@
|
|||
-- NOTE: Leader before plugins are loaded (otherwise wrong leader will be used)
|
||||
|
||||
-- Check Neovim version requirement
|
||||
if vim.fn.has 'nvim-0.11' == 0 then
|
||||
vim.api.nvim_err_writeln 'Error: Neovim 0.11 or higher is required for this configuration.'
|
||||
vim.api.nvim_err_writeln('Current version: ' .. vim.version().major .. '.' .. vim.version().minor .. '.' .. vim.version().patch)
|
||||
vim.api.nvim_err_writeln 'Please update Neovim to continue.'
|
||||
return
|
||||
end
|
||||
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
-- User settings
|
||||
vim.g.tabnine_enable = true -- JCM
|
||||
vim.g.autocomplete_enable = true
|
||||
-- vim.o.autochdir = true -- to open from buffer dir
|
||||
vim.g.format_on_save_enabled = true
|
||||
|
||||
-- Add emacs/rl keybindings to this configuration?
|
||||
vim.g.neovimacs_bindings = true
|
||||
vim.g.neovimacs_insert = true
|
||||
|
||||
-- Margins
|
||||
vim.opt.title = false -- in status, not great with tmux
|
||||
vim.opt.number = true -- show line number
|
||||
vim.opt.relativenumber = false
|
||||
vim.opt.showmode = false
|
||||
vim.opt.signcolumn = 'yes'
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.scrolloff = 10
|
||||
vim.opt.colorcolumn = '120'
|
||||
-- vim.opt.breakindent = true
|
||||
vim.o.title = false -- in status, not great with tmux
|
||||
vim.o.number = true -- show line number
|
||||
vim.o.relativenumber = false
|
||||
vim.o.showmode = false
|
||||
vim.o.signcolumn = 'yes'
|
||||
vim.o.cursorline = true
|
||||
vim.o.scrolloff = 10
|
||||
vim.o.colorcolumn = '120'
|
||||
vim.o.guicursor = 'n-v-i-c:block-Cursor' -- keep block cursor
|
||||
-- vim.o.breakindent = true
|
||||
|
||||
-- TODO: replace with osc52 provider once iTerm2 supports it better
|
||||
if vim.env.DISPLAY then
|
||||
|
|
@ -21,61 +41,66 @@ if vim.env.DISPLAY then
|
|||
vim.opt.clipboard:append { 'unnamed', 'unnamedplus' }
|
||||
end)
|
||||
end
|
||||
vim.opt.mouse = 'nvi'
|
||||
vim.o.mouse = 'nvi'
|
||||
end
|
||||
|
||||
-- File related
|
||||
vim.opt.autochdir = false
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.undofile = true
|
||||
vim.opt.undodir = os.getenv 'HOME' .. '/.vim/undodir'
|
||||
vim.o.swapfile = false
|
||||
vim.o.backup = false
|
||||
vim.o.writebackup = false
|
||||
vim.o.undofile = true
|
||||
vim.o.undodir = os.getenv 'HOME' .. '/.vim/undodir'
|
||||
if vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then
|
||||
vim.opt.fileformats = 'dos,unix,mac'
|
||||
vim.o.fileformats = 'dos,unix,mac'
|
||||
elseif vim.fn.has 'mac' == 1 then
|
||||
vim.opt.fileformats = 'mac,unix,dos'
|
||||
vim.o.fileformats = 'mac,unix,dos'
|
||||
else
|
||||
vim.opt.fileformats = 'unix,dos,mac'
|
||||
vim.o.fileformats = 'unix,dos,mac'
|
||||
end
|
||||
vim.opt.wildmenu = true
|
||||
vim.opt.wildmode = 'list:longest,list:full' -- list choices, expand singles
|
||||
vim.o.wildmenu = true
|
||||
vim.o.wildmode = 'list:longest,list:full' -- expand to longest match, then list choices
|
||||
vim.keymap.set('n', '<leader>p', '', { desc = '[P] +Explore' })
|
||||
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = 'Open explorer [V]' })
|
||||
|
||||
-- Search
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.wrapscan = false
|
||||
vim.opt.inccommand = 'split' -- preview
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
vim.o.wrapscan = false
|
||||
vim.o.inccommand = 'split' -- preview
|
||||
|
||||
-- Performance
|
||||
vim.opt.updatetime = 250
|
||||
vim.opt.timeoutlen = 300
|
||||
vim.o.updatetime = 250
|
||||
vim.o.timeoutlen = 3000
|
||||
|
||||
-- Windows
|
||||
-- :sp/:vsp to split windows
|
||||
-- C-w to jump between them
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
vim.o.splitright = true
|
||||
vim.o.splitbelow = true
|
||||
|
||||
-- Whitespace
|
||||
vim.opt.list = true
|
||||
vim.o.list = true
|
||||
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
||||
|
||||
-- Spelling: "z=" in normal to suggest replacements
|
||||
vim.opt.spelllang = 'en_us'
|
||||
vim.opt.spell = true
|
||||
vim.o.spelllang = 'en_us'
|
||||
vim.o.spell = true
|
||||
|
||||
-- Diagnostics
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
vim.keymap.set('n', '<leader>td', function()
|
||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||
end, { silent = true, noremap = true, desc = 'Toggle [D]iagnostics' })
|
||||
-- Quick diagnostics
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = '[Q]uickfix diagnostics' })
|
||||
|
||||
-- Allow 'q' to close simple diagnostic windows
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = { 'qf', 'help', 'checkhealth' },
|
||||
callback = function()
|
||||
vim.keymap.set('n', 'q', '<cmd>bd<cr>', { silent = true, buffer = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Highlight when yanking (copying) text - "yap"
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
desc = 'Highlight when yanking (copying) text',
|
||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
||||
group = vim.api.nvim_create_augroup('ks-highlight-yank', { clear = true }),
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
|
|
@ -83,16 +108,17 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
|||
|
||||
-- Install Lazy from Github
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
local uv = vim.uv or vim.loop
|
||||
|
||||
if not uv.fs_stat(lazypath) then
|
||||
if not vim.uv.fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
|
||||
if vim.v.shell_error ~= 0 then
|
||||
error('Error cloning lazy.nvim:\n' .. out)
|
||||
end
|
||||
end ---@diagnostic disable-next-line: undefined-field
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
local rtp = vim.opt.rtp
|
||||
rtp:prepend(lazypath)
|
||||
|
||||
-- :Lazy
|
||||
require('lazy').setup({
|
||||
|
|
@ -104,26 +130,19 @@ require('lazy').setup({
|
|||
require 'plugins.gitsigns', -- Add git changes to gutter
|
||||
require 'plugins.which-key', -- Show keybindings as you go
|
||||
require 'plugins.telescope', -- Fuzzy finder (file & LSP search)
|
||||
require 'plugins.lsp', -- Language server (types, errors, signatures)
|
||||
require 'plugins.lualine', -- Statusbar at bottom
|
||||
require 'plugins.mason', -- Mason: LSP/DAP/Linter/Formatter installer
|
||||
require 'plugins.conform', -- Auto-reformat files on save
|
||||
require 'plugins.claude-code', -- LLM: Claude Code
|
||||
require 'plugins.venv', -- Virtual environment selection
|
||||
require 'plugins.autocomplete', -- Auto-completion
|
||||
require 'plugins.autocomplete-blink', -- Auto-completion (new, incomplete)
|
||||
require 'plugins.colorscheme', -- Color scheme
|
||||
require 'plugins.misc', -- Misc small plugins
|
||||
require 'plugins.mini', -- Misc small plugins
|
||||
require 'plugins.treesitter', -- Code highlights and reference navigation
|
||||
require 'plugins.todo', -- Highlight todo, notes in comments
|
||||
require 'plugins.tabnine', -- Tabnine LLM coding assistant
|
||||
|
||||
-- Treesitter navigation
|
||||
-- :help nvim-treesitter
|
||||
-- :Telescope help_tags
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
-- To see keymaps do this:
|
||||
-- - Insert mode: <c-/>
|
||||
-- - Normal mode: ?
|
||||
-- Venv selector
|
||||
-- WIP: https://github.com/linux-cultist/venv-selector.nvim/tree/regexp
|
||||
-- Wait for a updated release
|
||||
require 'plugins.avante', -- LLM: Cursor alternative
|
||||
require 'plugins.tabnine', -- LLM: Tabnine coding assistant
|
||||
require 'plugins.tiny-inline-diagnostics', -- Better diagnostics
|
||||
}, {
|
||||
ui = {
|
||||
-- If you are using a Nerd Font: set icons to an empty table which will use the
|
||||
|
|
@ -166,12 +185,15 @@ local function recenter_and_refresh()
|
|||
end
|
||||
vim.keymap.set('n', '<C-l>', recenter_and_refresh, { noremap = true, silent = true })
|
||||
vim.keymap.set('i', '<C-l>', recenter_and_refresh, { noremap = true, silent = true })
|
||||
vim.keymap.set('c', '<C-s>', '<CR>n', { expr = true })
|
||||
|
||||
--- (Re)Undefine undesirable behavior
|
||||
vim.api.nvim_set_keymap('i', '<Esc>', '<Esc>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-a>', '<Nop>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-x>', '<Nop>', { noremap = true })
|
||||
if vim.g.neovimacs_bindings then
|
||||
vim.api.nvim_set_keymap('i', '<Esc>', '<Esc>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-a>', '<Nop>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-x><C-c>', ':confirm qall<CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-x><C-s>', ':update<CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-x><C-f>', ':hide edit ', { noremap = true })
|
||||
end
|
||||
|
||||
-- Terminals/Shell
|
||||
-- :terminal
|
||||
|
|
@ -181,55 +203,53 @@ vim.keymap.set('c', '<Up>', 'pumvisible() ? "<C-p>" : "<Up>"', { expr = true, no
|
|||
vim.keymap.set('c', '<Down>', 'pumvisible() ? "<C-n>" : "<Down>"', { expr = true, noremap = true })
|
||||
vim.keymap.set('c', '<Left>', 'pumvisible() ? "<C-b>" : "<Left>"', { expr = true, noremap = true })
|
||||
vim.keymap.set('c', '<Right>', 'pumvisible() ? "<C-f>" : "<Right>"', { expr = true, noremap = true })
|
||||
-- vim.opt.wildcharm = '<Tab>' -- set wildcharm=<C-Z>
|
||||
|
||||
-- LSP in insert mode
|
||||
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
update_in_insert = false,
|
||||
})
|
||||
-- LSP diagnostics configuration
|
||||
vim.diagnostic.config { virtual_text = false }
|
||||
|
||||
-- Tab management keys
|
||||
-- F1-Prev, F2-Next, F3-New, F4-Close
|
||||
--
|
||||
local function safe_tabclose()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local buf_windows = vim.call('win_findbuf', bufnr)
|
||||
local modified = vim.api.nvim_get_option_value('modified', { buf = bufnr })
|
||||
-- vim.diagnostic.config {
|
||||
-- virtual_text = {
|
||||
-- source = 'if_many',
|
||||
-- },
|
||||
-- signs = true,
|
||||
-- underline = true,
|
||||
-- update_in_insert = true,
|
||||
-- severity_sort = true,
|
||||
--}
|
||||
|
||||
if vim.fn.tabpagenr '$' == 1 then
|
||||
-- last tab, no-op
|
||||
return
|
||||
elseif modified and #buf_windows == 1 then
|
||||
vim.ui.input({
|
||||
prompt = 'Buffer modified, are you sure? ',
|
||||
}, function(input)
|
||||
if input == 'y' then
|
||||
vim.cmd 'tabclose'
|
||||
end
|
||||
end)
|
||||
else
|
||||
vim.cmd 'tabclose'
|
||||
-- Register and enable LSP servers
|
||||
-- See https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/configs
|
||||
-- for sample starter configurations.
|
||||
local lsp_servers = {
|
||||
'ast_grep',
|
||||
'clangd',
|
||||
'lua_ls',
|
||||
'bashls',
|
||||
'marksman',
|
||||
'python',
|
||||
'taplo',
|
||||
'yamlls',
|
||||
'ts_ls',
|
||||
'dockerls',
|
||||
}
|
||||
-- Conditional on executables
|
||||
if vim.fn.executable 'go' == 1 then
|
||||
table.insert(lsp_servers, 'gopls')
|
||||
end
|
||||
if vim.fn.executable 'nixd' == 1 then
|
||||
table.insert(lsp_servers, 'nil_ls')
|
||||
end
|
||||
|
||||
require 'lsp/keybindings'
|
||||
for _, server in ipairs(lsp_servers) do
|
||||
local ok, config = pcall(require, 'lsp.' .. server)
|
||||
if ok and config.name then
|
||||
vim.lsp.config[config.name] = config
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
end
|
||||
vim.keymap.set('t', '<F1>', vim.cmd.tabp, { noremap = true, silent = true })
|
||||
vim.keymap.set('t', '<F2>', vim.cmd.tabn, { noremap = true, silent = true })
|
||||
vim.keymap.set('t', '<F3>', '<C-\\><C-n>:tabnew<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('t', '', '<C-\\><C-n>:tabnew<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('t', '<F4>', safe_tabclose, { noremap = true, silent = true })
|
||||
vim.keymap.set('t', '<F5>', '<C-\\><C-n><Esc>:tab new<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<F1>', vim.cmd.tabp, { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<F2>', vim.cmd.tabn, { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<F3>', ':tabnew<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '', ':tabnew<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<F4>', safe_tabclose, { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<F5>', ':tab term<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('i', '<F1>', vim.cmd.tabp, { noremap = true, silent = true })
|
||||
vim.keymap.set('i', '<F2>', vim.cmd.tabn, { noremap = true, silent = true })
|
||||
vim.keymap.set('i', '<F3>', '<Esc>:tabnew<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('i', '', '<Esc>:tabnew<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('i', '<F4>', safe_tabclose, { noremap = true, silent = true })
|
||||
vim.keymap.set('i', '<F5>', '<Esc>:tab term<CR>', { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<leader>tp', vim.cmd.tabn, { desc = 'Tab [p]revious' })
|
||||
vim.keymap.set('n', '<leader>tn', vim.cmd.tabp, { desc = 'Tab [n]ext' })
|
||||
vim.keymap.set('n', '<leader>to', vim.cmd.tabnew, { desc = 'Tab [o]pen' })
|
||||
vim.keymap.set('n', '<leader>tc', safe_tabclose, { desc = 'Tab [c]lose' })
|
||||
|
||||
-- Inlay hints?
|
||||
vim.lsp.inlay_hint.enable(true)
|
||||
|
||||
require 'utils/windows'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue