summaryrefslogtreecommitdiff
path: root/files/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'files/nvim')
-rw-r--r--files/nvim/init.vim72
-rw-r--r--files/nvim/mini_starter_picture.diff57
2 files changed, 74 insertions, 55 deletions
diff --git a/files/nvim/init.vim b/files/nvim/init.vim
index 017f128..7325928 100644
--- a/files/nvim/init.vim
+++ b/files/nvim/init.vim
@@ -58,30 +58,39 @@ set clipboard+=unnamedplus
" Session options.
set ssop=skiprtp,blank,buffers,folds,winsize,terminal
set vop-=curdir
-let view_dir = expand('~/c/sessions/views')
-if !isdirectory(view_dir)
- call mkdir(view_dir, 'p', 0700)
-endif
-let &viewdir=view_dir
+if isdirectory(expand('~/c'))
+ let view_dir = expand('~/c/sessions/views')
+ if !isdirectory(view_dir)
+ call mkdir(view_dir, 'p', 0755)
+ endif
+ let &viewdir=view_dir
-" Staggered backups.
-if isdirectory(expand('/mnt/store/backup/vim'))
- set backupdir=/mnt/store/backup/vim//
-else
- set backupdir=~/c/sessions/backup//
-endif
-set backup
+ " Staggered backups.
+ let backup_dir = '/mnt/store/backup/vim'
+ if !isdirectory(backup_dir)
+ let backup_dir = expand('~/c/sessions/backup//')
+ if !isdirectory(backup_dir)
+ call mkdir(backup_dir, 'p', 0755)
+ endif
+ endif
+ let &backupdir=backup_dir
+ set backup
-" Swap file directory.
-set directory=~/c/sessions/swaps//
+ " Swap file directory.
+ let swap_dir = expand('~/c/sessions/swaps//')
+ if !isdirectory(swap_dir)
+ call mkdir(swap_dir, 'p', 0755)
+ endif
+ let &directory=swap_dir
-if has('persistent_undo')
- let undo_dir = expand('~/c/sessions/undo')
- if !isdirectory(undo_dir)
- call mkdir(undo_dir, 'p', 0700)
+ if has('persistent_undo')
+ let undo_dir = expand('~/c/sessions/undo')
+ if !isdirectory(undo_dir)
+ call mkdir(undo_dir, 'p', 0755)
+ endif
+ let &undodir=undo_dir
+ set undofile
endif
- let &undodir=undo_dir
- set undofile
endif
" Colorscheme.
@@ -240,7 +249,11 @@ function get_lsp_name()
if next(active_clients) == nil then
return ''
else
- return '+'..active_clients[1].name
+ str = '<'
+ for _, v in pairs(active_clients) do
+ str = str .. v.name .. '+'
+ end
+ return str:sub(1, -2) .. '>'
end
end
@@ -257,8 +270,7 @@ end
-- LSP configs.
if os.getenv('NIX_SHELL') ~= nil then
vim.diagnostic.config({ virtual_text = true })
- local lsp = require('lspconfig')
- lsp.clangd.setup({
+ vim.lsp.config('clangd', {
cmd = {
'clangd',
'-j=4',
@@ -285,7 +297,7 @@ if os.getenv('NIX_SHELL') ~= nil then
}
},
})
- lsp.ruff.setup({})
+ vim.lsp.enable({'clangd', 'ruff', 'ty'})
-- https://github.com/neovim/nvim-lspconfig/issues/2626#issuecomment-2117022664
-- https://github.com/neovim/nvim-lspconfig/issues/2508
vim.api.nvim_create_autocmd('BufReadPre', {
@@ -306,11 +318,13 @@ if os.getenv('NIX_SHELL') ~= nil then
end
-- Set sessions folder and autowrite.
-require('mini.sessions').setup({
- autoread = false,
- autowrite = true,
- directory = '~/c/sessions'
-})
+if vim.fn.isdirectory(vim.fn.expand('~/c')) then
+ require('mini.sessions').setup({
+ autoread = false,
+ autowrite = true,
+ directory = '~/c/sessions'
+ })
+end
-- Completion.
require('mini.completion').setup({
diff --git a/files/nvim/mini_starter_picture.diff b/files/nvim/mini_starter_picture.diff
index 3ecd564..b64025c 100644
--- a/files/nvim/mini_starter_picture.diff
+++ b/files/nvim/mini_starter_picture.diff
@@ -1,5 +1,5 @@
diff --git a/lua/mini/starter.lua b/lua/mini/starter.lua
-index 3e0570f3..0f4a384e 100644
+index cc10d101..78c4e5c1 100644
--- a/lua/mini/starter.lua
+++ b/lua/mini/starter.lua
@@ -138,7 +138,7 @@
@@ -11,7 +11,7 @@ index 3e0570f3..0f4a384e 100644
--- timer:stop()
--- return
--- end
-@@ -239,6 +239,9 @@ MiniStarter.config = {
+@@ -248,6 +248,9 @@ MiniStarter.config = {
-- If `nil` (default), default items will be used (see |mini.starter|).
items = nil,
@@ -21,7 +21,7 @@ index 3e0570f3..0f4a384e 100644
-- Header to be displayed before items. Converted to single string via
-- `tostring` (use `\n` to display several lines). If function, it is
-- evaluated first. If `nil` (default), polite greeting will be used.
-@@ -249,6 +252,12 @@ MiniStarter.config = {
+@@ -258,6 +261,12 @@ MiniStarter.config = {
-- evaluated first. If `nil` (default), default usage help will be shown.
footer = nil,
@@ -34,7 +34,7 @@ index 3e0570f3..0f4a384e 100644
-- Array of functions to be applied consecutively to initial content.
-- Each function should take and return content for Starter buffer (see
-- |mini.starter| and |MiniStarter.get_content()| for more details).
-@@ -373,7 +382,7 @@ MiniStarter.refresh = function(buf_id)
+@@ -382,7 +391,7 @@ MiniStarter.refresh = function(buf_id)
data.footer = H.normalize_header_footer(config.footer or H.default_footer)
-- Evaluate content
@@ -43,20 +43,24 @@ index 3e0570f3..0f4a384e 100644
local hooks = config.content_hooks or H.default_content_hooks
for _, f in ipairs(hooks) do
content = f(content, buf_id)
-@@ -400,6 +409,12 @@ MiniStarter.refresh = function(buf_id)
+@@ -409,6 +418,16 @@ MiniStarter.refresh = function(buf_id)
-- Apply current query (clear command line afterwards)
H.make_query(buf_id)
+
-+ local timer = vim.loop.new_timer()
-+ timer:start(0, 0, vim.schedule_wrap(function()
-+ timer:stop()
-+ H.draw_picture(config, false)
-+ end))
++ -- The picture drawn here used to get cleared at some point
++ -- that _usually_ came before any scheduled timers fired.
++ -- That seems to not happen anymore (nvim-0.11.1, kitty 0.42.1).
++ H.draw_picture(config, false)
++ --local timer = vim.loop.new_timer()
++ --timer:start(0, 0, vim.schedule_wrap(function()
++ -- timer:stop()
++ -- H.draw_picture(config, false)
++ --end))
end
--- Close Starter buffer
-@@ -731,18 +746,45 @@ MiniStarter.gen_hook.aligning = function(horizontal, vertical)
+@@ -738,18 +757,45 @@ MiniStarter.gen_hook.aligning = function(horizontal, vertical)
local win_id = vim.fn.bufwinid(buf_id)
if win_id < 0 then return end
@@ -104,7 +108,7 @@ index 3e0570f3..0f4a384e 100644
return MiniStarter.gen_hook.padding(left_pad, top_pad)(content)
end
end
-@@ -1005,7 +1047,7 @@ H.default_footer = [[
+@@ -1012,7 +1058,7 @@ H.default_footer = [[
Type query to filter items
<BS> deletes latest character from query
<Esc> resets current query
@@ -113,7 +117,7 @@ index 3e0570f3..0f4a384e 100644
<CR> executes action of current item
<C-c> closes this buffer]]
-@@ -1046,8 +1088,54 @@ end
+@@ -1053,8 +1099,54 @@ end
H.apply_config = function(config) MiniStarter.config = config end
@@ -169,7 +173,7 @@ index 3e0570f3..0f4a384e 100644
if config.autoopen then
local on_vimenter = function()
-@@ -1059,7 +1147,7 @@ H.create_autocommands = function(config)
+@@ -1066,7 +1158,7 @@ H.create_autocommands = function(config)
vim.cmd('noautocmd lua MiniStarter.open()')
end
@@ -178,7 +182,7 @@ index 3e0570f3..0f4a384e 100644
vim.api.nvim_create_autocmd('VimEnter', au_opts)
end
-@@ -1105,9 +1193,11 @@ H.normalize_header_footer = function(x)
+@@ -1112,9 +1204,11 @@ H.normalize_header_footer = function(x)
end
-- Work with buffer content ---------------------------------------------------
@@ -191,7 +195,7 @@ index 3e0570f3..0f4a384e 100644
-- Add header lines
for _, l in ipairs(header) do
H.content_add_line(content, { H.content_unit(l, 'header', 'MiniStarterHeader') })
-@@ -1118,7 +1208,7 @@ H.make_initial_content = function(header, items, footer)
+@@ -1125,7 +1219,7 @@ H.make_initial_content = function(header, items, footer)
H.content_add_items(content, items)
-- Add footer lines
@@ -200,7 +204,7 @@ index 3e0570f3..0f4a384e 100644
for _, l in ipairs(footer) do
H.content_add_line(content, { H.content_unit(l, 'footer', 'MiniStarterFooter') })
end
-@@ -1321,11 +1411,22 @@ H.make_buffer_autocmd = function(buf_id)
+@@ -1328,11 +1422,23 @@ H.make_buffer_autocmd = function(buf_id)
au('VimResized', function() MiniStarter.refresh(buf_id) end, 'Refresh')
au('CursorMoved', function() H.position_cursor_on_current_item(buf_id) end, 'Position cursor')
@@ -214,16 +218,17 @@ index 3e0570f3..0f4a384e 100644
end, 'On BufLeave')
+
+ au('BufEnter', function()
-+ local timer = vim.loop.new_timer()
-+ timer:start(0, 0, vim.schedule_wrap(function()
-+ timer:stop()
-+ H.draw_picture(config, false)
-+ end))
++ H.draw_picture(config, false)
++ --local timer = vim.loop.new_timer()
++ --timer:start(0, 0, vim.schedule_wrap(function()
++ -- timer:stop()
++ -- H.draw_picture(config, false)
++ --end))
+ end, 'On BufEnter')
end
H.apply_buffer_options = function(buf_id)
-@@ -1338,7 +1439,7 @@ H.apply_buffer_options = function(buf_id)
+@@ -1345,7 +1451,7 @@ H.apply_buffer_options = function(buf_id)
vim.api.nvim_feedkeys('\28\14', 'nx', false)
-- Having `noautocmd` is crucial for performance: ~9ms without it, ~1.6ms with it
@@ -232,7 +237,7 @@ index 3e0570f3..0f4a384e 100644
local options = {
-- Taken from 'vim-startify'
-@@ -1385,12 +1486,8 @@ H.apply_buffer_mappings = function(buf_id)
+@@ -1392,12 +1498,8 @@ H.apply_buffer_mappings = function(buf_id)
buf_keymap('<CR>', 'MiniStarter.eval_current_item()')
@@ -247,7 +252,7 @@ index 3e0570f3..0f4a384e 100644
-- Make all special symbols to update query
for _, key in ipairs(vim.split(H.get_config().query_updaters, '')) do
-@@ -1466,21 +1563,21 @@ H.is_something_shown = function()
+@@ -1473,21 +1575,21 @@ H.is_something_shown = function()
end
-- Utilities ------------------------------------------------------------------
@@ -272,7 +277,7 @@ index 3e0570f3..0f4a384e 100644
-- Avoid hit-enter-prompt
local max_width = vim.o.columns * math.max(vim.o.cmdheight - 1, 0) + vim.v.echospace
-@@ -1529,7 +1626,7 @@ H.eval_fun_or_string = function(x, string_as_cmd)
+@@ -1536,7 +1638,7 @@ H.eval_fun_or_string = function(x, string_as_cmd)
if type(x) == 'function' then return x() end
if type(x) == 'string' then
if string_as_cmd then