Added blink.cmp buffer completions for markdown/text + some useful options/autocommands
This commit is contained in:
parent
3338d39206
commit
ddca0b4504
64
init.lua
64
init.lua
|
@ -166,6 +166,15 @@ vim.o.scrolloff = 10
|
||||||
-- See `:help 'confirm'`
|
-- See `:help 'confirm'`
|
||||||
vim.o.confirm = true
|
vim.o.confirm = true
|
||||||
|
|
||||||
|
-- Enable undo/redo changes even after closing and reopening a file
|
||||||
|
vim.opt.undofile = true
|
||||||
|
|
||||||
|
-- Enable smooth scrolling
|
||||||
|
vim.opt.smoothscroll = true
|
||||||
|
|
||||||
|
-- Highlight max chars per line
|
||||||
|
-- vim.opt.colorcolumn = '100'
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
-- [[ Basic Keymaps ]]
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
|
|
||||||
|
@ -184,6 +193,9 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
|
||||||
-- or just use <C-\><C-n> to exit terminal mode
|
-- or just use <C-\><C-n> to exit terminal mode
|
||||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||||
|
|
||||||
|
-- Close current buffer
|
||||||
|
vim.keymap.set('n', '<leader>Q', ':bd<CR>', { desc = 'Close current buffer' })
|
||||||
|
|
||||||
-- TIP: Disable arrow keys in normal mode
|
-- TIP: Disable arrow keys in normal mode
|
||||||
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
||||||
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
||||||
|
@ -215,10 +227,46 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
desc = 'Highlight when yanking (copying) text',
|
desc = 'Highlight when yanking (copying) text',
|
||||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.hl.on_yank()
|
vim.hl.on_yank { timeout = 200 }
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Restore cursor position on file open
|
||||||
|
vim.api.nvim_create_autocmd('BufReadPost', {
|
||||||
|
desc = 'Restore cursor position on file open',
|
||||||
|
group = vim.api.nvim_create_augroup('kickstart-restore-cursor', { clear = true }),
|
||||||
|
pattern = '*',
|
||||||
|
callback = function()
|
||||||
|
local line = vim.fn.line '\'"'
|
||||||
|
if line > 1 and line <= vim.fn.line '$' then
|
||||||
|
vim.cmd 'normal! g\'"'
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- auto-create missing dirs when saving a file
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
desc = 'Auto-create missing dirs when saving a file',
|
||||||
|
group = vim.api.nvim_create_augroup('kickstart-auto-create-dir', { clear = true }),
|
||||||
|
pattern = '*',
|
||||||
|
callback = function()
|
||||||
|
local dir = vim.fn.expand '<afile>:p:h'
|
||||||
|
if vim.fn.isdirectory(dir) == 0 then
|
||||||
|
vim.fn.mkdir(dir, 'p')
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- disable automatic comment on newline
|
||||||
|
-- vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
-- desc = 'Disable automatic comment on newline',
|
||||||
|
-- group = vim.api.nvim_create_augroup('kickstart-disable-auto-comment', { clear = true }),
|
||||||
|
-- pattern = '*',
|
||||||
|
-- callback = function()
|
||||||
|
-- vim.opt_local.formatoptions:remove { 'c', 'r', 'o' }
|
||||||
|
-- end,
|
||||||
|
-- })
|
||||||
|
|
||||||
-- [[ Install `lazy.nvim` plugin manager ]]
|
-- [[ Install `lazy.nvim` plugin manager ]]
|
||||||
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
|
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
|
||||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||||
|
@ -854,9 +902,21 @@ require('lazy').setup({
|
||||||
},
|
},
|
||||||
|
|
||||||
sources = {
|
sources = {
|
||||||
default = { 'lsp', 'path', 'snippets', 'lazydev' },
|
default = { 'lsp', 'path', 'snippets', 'lazydev', 'buffer' },
|
||||||
providers = {
|
providers = {
|
||||||
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
|
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
|
||||||
|
buffer = {
|
||||||
|
score_offset = -1,
|
||||||
|
filter = function(buffer)
|
||||||
|
-- Filetypes for which buffer completions are enabled; add filetypes to extend
|
||||||
|
local enabled_filetypes = {
|
||||||
|
'markdown',
|
||||||
|
'text',
|
||||||
|
}
|
||||||
|
local filetype = vim.bo[buffer].filetype
|
||||||
|
return vim.tbl_contains(enabled_filetypes, filetype)
|
||||||
|
end,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue