-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Enhance Kickstart.nvim UX with Buffer Completions, Options, and Autocommands #1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
ddca0b4
13ba71f
87d4ff8
c2347a5
c61d50d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,15 @@ vim.o.scrolloff = 10 | |
-- See `:help 'confirm'` | ||
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 ]] | ||
-- 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 | ||
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' }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this is not very useful because What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback, I agree that However, since Kickstart.nvim is primarily aimed at users new to Neovim, I think keeping the |
||
|
||
-- TIP: Disable arrow keys in normal mode | ||
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h 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', | ||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), | ||
callback = function() | ||
vim.hl.on_yank() | ||
vim.hl.on_yank { timeout = 200 } | ||
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, | ||
}) | ||
MN-nagy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
-- 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, | ||
-- }) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this might be too niche There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a fair point. My goal with adding these autocommands was to give users a better idea of what's possible with them, as the original repo only included just one example. If you still think it's too much to add to What do you think? |
||
-- [[ Install `lazy.nvim` plugin manager ]] | ||
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info | ||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' | ||
|
@@ -854,9 +902,22 @@ require('lazy').setup({ | |
}, | ||
|
||
sources = { | ||
default = { 'lsp', 'path', 'snippets', 'lazydev' }, | ||
default = { 'lsp', 'path', 'snippets', 'lazydev', 'buffer' }, | ||
providers = { | ||
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, | ||
buffer = { | ||
-- Make buffer compeletions appear at the end. | ||
score_offset = -100, | ||
enabled = function() | ||
-- Filetypes for which buffer completions are enabled; add filetypes to extend: | ||
local enabled_filetypes = { | ||
'markdown', | ||
'text', | ||
} | ||
local filetype = vim.bo.filetype | ||
return vim.tbl_contains(enabled_filetypes, filetype) | ||
end, | ||
}, | ||
}, | ||
}, | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.