Skip to content

Commit

Permalink
fix: timeouts and other options
Browse files Browse the repository at this point in the history
  • Loading branch information
rafi committed May 17, 2024
1 parent 4f0f6e0 commit dab7fd1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 35 deletions.
41 changes: 15 additions & 26 deletions lua/rafi/config/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = ';'

-- Enable LazyVim auto format
-- LazyVim auto format
vim.g.autoformat = false

-- Enable elite-mode (hjkl mode. arrow-keys resize window)
Expand Down Expand Up @@ -51,14 +51,14 @@ opt.spelllang = { 'en' }
opt.spelloptions:append('camel')
opt.updatetime = 200 -- Idle time to write swap and trigger CursorHold
if not vim.g.vscode then
opt.timeoutlen = 300 -- Time out on mappings
end
if not vim.env.SSH_TTY then
-- only set clipboard if not in ssh, to make sure the OSC 52
-- integration works automatically. Requires Neovim >= 0.10.0
opt.clipboard = 'unnamedplus' -- Sync with system clipboard
opt.timeoutlen = 500 -- Time out on mappings
opt.ttimeoutlen = 10 -- Time out on key codes
end

-- only set clipboard if not in ssh, to make sure the OSC 52
-- integration works automatically. Requires Neovim >= 0.10.0
opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard

opt.completeopt = 'menu,menuone,noinsert'
opt.wildmode = 'longest:full,full'
opt.diffopt:append({ 'indent-heuristic', 'algorithm:patience' })
Expand Down Expand Up @@ -114,6 +114,8 @@ end
opt.wrap = false -- No wrap by default
opt.linebreak = true -- Break long lines at 'breakat'
opt.breakindent = true
opt.formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()"

opt.formatoptions = opt.formatoptions
- 'a' -- Auto formatting is BAD.
- 't' -- Don't auto format my code. I got linters for that.
Expand All @@ -138,6 +140,7 @@ opt.numberwidth = 2 -- Minimum number of columns to use for the line numbe
opt.number = false -- Don't show line numbers
opt.ruler = false -- Disable default status ruler
opt.list = true -- Show hidden characters
opt.foldlevel = 99
opt.cursorline = true -- Highlight the text line under the cursor
opt.splitbelow = true -- New split at bottom
opt.splitright = true -- New split on right
Expand Down Expand Up @@ -179,32 +182,18 @@ opt.fillchars = {
verthoriz = '',
}

if vim.fn.has('nvim-0.10') == 1 then
opt.smoothscroll = true
end

-- Folds
-- ===

opt.foldlevel = 99
opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]]

if vim.fn.has('nvim-0.9.0') == 1 then
vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]]
vim.opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()"
end

-- HACK: causes freezes on <= 0.9, so only enable on >= 0.10 for now
if vim.fn.has('nvim-0.10') == 1 then
vim.opt.foldmethod = 'expr'
opt.smoothscroll = true
vim.opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
vim.opt.foldtext = ""
vim.opt.fillchars = "fold: "
vim.opt.foldmethod = 'expr'
vim.opt.foldtext = ''
else
vim.opt.foldmethod = 'indent'
vim.opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
end

vim.o.formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()"

-- Misc
-- ===

Expand Down
17 changes: 10 additions & 7 deletions lua/rafi/plugins/coding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ return {
end
local entry = event.entry
local item = entry:get_completion_item()
if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) then
local keys =
vim.api.nvim_replace_termcodes('()<left>', false, false, true)
vim.api.nvim_feedkeys(keys, 'i', true)
if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) and item.insertTextFormat ~= 2 then
local cursor = vim.api.nvim_win_get_cursor(0)
local prev_char = vim.api.nvim_buf_get_text(0, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2] + 1, {})[1]
if prev_char ~= '(' and prev_char ~= ')' then
local keys =
vim.api.nvim_replace_termcodes('()<left>', false, false, true)
vim.api.nvim_feedkeys(keys, 'i', true)
end
end
end)
end,
Expand Down Expand Up @@ -205,14 +209,13 @@ return {
{
'<leader>up',
function()
local Util = require('lazy.core.util')
vim.g.autopairs_disable = not vim.g.autopairs_disable
if vim.g.autopairs_disable then
require('nvim-autopairs').disable()
Util.warn('Disabled auto pairs', { title = 'Option' })
LazyVim.warn('Disabled auto pairs', { title = 'Option' })
else
require('nvim-autopairs').enable()
Util.info('Enabled auto pairs', { title = 'Option' })
LazyVim.info('Enabled auto pairs', { title = 'Option' })
end
end,
desc = 'Toggle auto pairs',
Expand Down
12 changes: 10 additions & 2 deletions lua/rafi/plugins/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,22 @@ return {
'folke/flash.nvim',
event = 'VeryLazy',
vscode = true,
opts = {},
---@diagnostic disable-next-line: undefined-doc-name
---@type Flash.Config
opts = {
modes = {
search = {
enabled = false,
},
},
},
-- stylua: ignore
keys = {
{ 'ss', mode = { 'n', 'x', 'o' }, function() require('flash').jump() end, desc = 'Flash' },
{ 'S', mode = { 'n', 'x', 'o' }, function() require('flash').treesitter() end, desc = 'Flash Treesitter' },
{ 'r', mode = 'o', function() require('flash').remote() end, desc = 'Remote Flash' },
{ 'R', mode = { 'x', 'o' }, function() require('flash').treesitter_search() end, desc = 'Treesitter Search' },
{ '<c-s>', mode = { 'c' }, function() require('flash').toggle() end, desc = 'Toggle Flash Search' },
{ '<C-s>', mode = { 'c' }, function() require('flash').toggle() end, desc = 'Toggle Flash Search' },
},
},

Expand Down
5 changes: 5 additions & 0 deletions lua/rafi/plugins/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Plugins initialization
-- https://github.com/rafi/vim-config

if vim.fn.has('nvim-0.9.0') == 0 then
vim.api.nvim_echo({
{ 'RafiVim requires Neovim >= 0.9.0\n', 'ErrorMsg' },
Expand All @@ -11,6 +14,8 @@ end
require('rafi.config').init()

return {
-- Modern plugin manager for Neovim
{ 'folke/lazy.nvim', version = '*' },
-- Lua functions library
{ 'nvim-lua/plenary.nvim', lazy = false },
}

0 comments on commit dab7fd1

Please sign in to comment.