/nvim-backup1 v2
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.o.number = true
vim.o.mouse = 'a'
vim.o.showmode = false
vim.schedule(function()
vim.o.clipboard = 'unnamedplus'
end)
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.cursorline = true
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.hl.on_yank()
end,
})
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).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
local rtp = vim.opt.rtp
rtp:prepend(lazypath)
require('lazy').setup({
{ -- You can easily change to a different colorscheme.
'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins.
config = function()
---@diagnostic disable-next-line: missing-fields
require('tokyonight').setup {
styles = {
comments = { italic = false }, -- Disable italics in comments
},
}
vim.cmd.colorscheme 'tokyonight-night'
end,
},
-- Highlight todo, notes, etc in comments
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
-- {
-- 'MeanderingProgrammer/render-markdown.nvim',
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.nvim' }, -- if you use the mini.nvim suite
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.icons' }, -- if you use standalone mini plugins
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
---@module 'render-markdown'
---@type render.md.UserConfig
-- opts = {},
-- }
})
-- Define a custom highlight group "GlowingBlue"
-- vim.api.nvim_command('highlight GlowingBlue guifg=#00afff guibg=NONE gui=bold')
-- Create a match for lines starting with "# Question"
-- vim.api.nvim_command('match GlowingBlue /^# Question.*/')
vim.cmd('highlight GlowingBlue guifg=#00afff guibg=NONE gui=bold')
vim.fn.matchadd('GlowingBlue', '^# Question.*')
vim.cmd('highlight RED_LINE guifg=#ff0000 guibg=NONE gui=bold')
vim.fn.matchadd('RED_LINE', '.*TODO.*')
vim.cmd([[
augroup remember_cursor
autocmd!
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
]])
vim.api.nvim_set_keymap('n', '<C-_>', 'gcc', { noremap = false, silent = true })
vim.api.nvim_create_autocmd({"BufEnter", "FileType"}, {
callback = function()
local cs = vim.bo.commentstring
if cs == "" or cs == nil then
vim.bo.commentstring = "# %s"
end
end,
})
-- Tab and indentation settings
vim.opt.tabstop = 4 -- Number of spaces a tab counts for
vim.opt.shiftwidth = 4 -- Number of spaces for each indentation level
vim.opt.expandtab = true -- Convert tabs to spaces
vim.opt.smartindent = true -- Smart autoindenting for new lines
vim.opt.autoindent = true -- Copy indent from current line when starting new line
vim.opt.softtabstop = 4 -- Number of spaces tab key inserts/deletes
-- Optional: Language-specific settings
vim.api.nvim_create_autocmd("FileType", {
pattern = {"javascript", "typescript", "json", "html", "css"},
callback = function()
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
vim.opt_local.softtabstop = 2
end,
})
-- For languages that prefer tabs over spaces
vim.api.nvim_create_autocmd("FileType", {
pattern = {"go", "makefile"},
callback = function()
vim.opt_local.expandtab = false
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
end,
})
-- Define a function to get the current mode in a human-readable form
local function mode()
local modes = {
['n'] = 'NORMAL',
['no'] = 'N·OPERATOR',
['v'] = 'VISUAL',
['V'] = 'V-LINE',
[''] = 'V-BLOCK',
['s'] = 'SELECT',
['S'] = 'S-LINE',
[''] = 'S-BLOCK',
['i'] = 'INSERT',
['ic'] = 'INSERT',
['R'] = 'REPLACE',
['Rv'] = 'V-REPLACE',
['c'] = 'COMMAND',
['cv'] = 'VIM EX',
['ce'] = 'EX',
['r'] = 'PROMPT',
['rm'] = 'MORE',
['r?'] = 'CONFIRM',
['!'] = 'SHELL',
['t'] = 'TERMINAL',
}
local current_mode = vim.api.nvim_get_mode().mode
return modes[current_mode] or current_mode
end
-- Get git branch name using vim's fugitive or gitsigns if available
local function git_branch()
local branch = ''
-- Try gitsigns
local ok, gs = pcall(require, 'gitsigns')
if ok and gs then
branch = gs.get_repo().head or ''
end
-- fallback: use vim's fugitive
if branch == '' then
branch = vim.fn.FugitiveHead()
end
if branch == '' then return '' end
return ' ' .. branch
end
-- Get file path relative to current working directory
local function filepath()
local fullpath = vim.fn.expand('%:~:.')
if fullpath == '' then
return '[No Name]'
end
return fullpath
end
-- Statusline setup
vim.o.statusline = table.concat {
'%#StatusLineMode#', -- highlight group for mode
' ', mode(), ' ', -- show mode with spaces
'%#StatusLineGit#', -- highlight for git
-- git_branch(), ' ',
'%#StatusLineFile#', -- highlight for file path
filepath(), ' ',
'%#StatusLineFiletype#', -- highlight for filetype
'%y', -- filetype
'%#StatusLinePos#', -- highlight for position info
' %l:%c ', -- line and column
'%p%%', -- percentage through file
}
-- Define highlight groups for the statusline
vim.cmd [[
highlight StatusLineMode guibg=#005f87 guifg=#ffffff gui=bold
highlight StatusLineGit guibg=#005f5f guifg=#ffd700 gui=bold
highlight StatusLineFile guibg=#303030 guifg=#87afff gui=bold
highlight StatusLineFiletype guibg=#303030 guifg=#d75f5f gui=italic
highlight StatusLinePos guibg=#303030 guifg=#af8700 gui=bold
]]
-- Optional: Make the statusline always visible
vim.o.laststatus = 2
-- Set rounded borders for completion popup
vim.opt.pumblend = 10 -- Optional: adds transparency
vim.opt.winblend = 10 -- Optional: adds transparency to floating windows
-- Configure completion menu appearance
vim.opt.completeopt = {'menu', 'menuone', 'noselect', 'preview'}
-- Set up rounded borders for the preview window
vim.api.nvim_create_autocmd('CompleteDone', {
callback = function()
local info = vim.fn.complete_add and vim.fn.complete_add or {}
if info.preview then
vim.api.nvim_win_set_config(0, { border = 'rounded' })
end
end,
})
-- Map Ctrl+. to trigger completion
vim.keymap.set('i', '<C-.>', '<C-x><C-n>', { desc = 'Trigger completion' })
vim.keymap.set('i', '<C-Space>', '<C-x><C-n>', { desc = 'Trigger completion' })
-- Alternative mappings for different completion types:
-- vim.keymap.set('i', '<C-.>', '<C-x><C-o>', { desc = 'Omni completion' }) -- For syntax-aware completion
-- vim.keymap.set('i', '<C-.>', '<C-x><C-f>', { desc = 'File completion' }) -- For file path completion
-- Better completion behavior
vim.opt.complete = 'w,b,u,t,i,k' -- Sources: current window, other windows, unloaded buffers, tags, included files, dictionary
vim.opt.completeopt = 'menu,menuone,noselect'
vim.opt.shortmess:append('c') -- Don't show completion messages
-- Set completion timing
vim.opt.updatetime = 300
vim.opt.timeoutlen = 500
-- Enable completion for different contexts
vim.keymap.set('i', '<C-x><C-f>', '<C-x><C-f>', { desc = 'File completion' })
vim.keymap.set('i', '<C-x><C-l>', '<C-x><C-l>', { desc = 'Line completion' })
vim.keymap.set('i', '<C-x><C-k>', '<C-x><C-k>', { desc = 'Dictionary completion' })
-- Better navigation in completion menu
vim.keymap.set('i', '<Tab>', function()
if vim.fn.pumvisible() == 1 then
return '<C-n>'
else
return '<Tab>'
end
end, { expr = true, desc = 'Next completion' })
vim.keymap.set('i', '<S-Tab>', function()
if vim.fn.pumvisible() == 1 then
return '<C-p>'
else
return '<S-Tab>'
end
end, { expr = true, desc = 'Previous completion' })
-- Accept completion with Enter
vim.keymap.set('i', '<CR>', function()
if vim.fn.pumvisible() == 1 then
return '<C-y>'
else
return '<CR>'
end
end, { expr = true, desc = 'Accept completion' })
-- Close completion with Escape
vim.keymap.set('i', '<Esc>', function()
if vim.fn.pumvisible() == 1 then
return '<C-e><Esc>'
else
return '<Esc>'
end
end, { expr = true, desc = 'Close completion' })
-- # TODO
-- markdown highliting
-- fix tab
-- fix close empty bugger bug?
-- telescope
-- mini.nvim?
-- lsp?