Skip to content

Commit 23399b4

Browse files
committed
tweaks to neovim.
1 parent 1cd1145 commit 23399b4

File tree

1 file changed

+109
-49
lines changed

1 file changed

+109
-49
lines changed

nvim/init.lua

Lines changed: 109 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require'packer'.startup {function (use)
1616
-- @return string
1717
-- https://github.com/aspeddro/dotfiles/blob/main/.config/nvim/lua/user/packages.lua
1818
local here = function(path)
19-
return vim.fn.expand '~/dev/' .. path
19+
return vim.fn.expand '~/src/' .. path
2020
end
2121

2222
---packer {{{
@@ -56,7 +56,7 @@ require'packer'.startup {function (use)
5656
}
5757
---}}}
5858

59-
---tree {{{
59+
---nnn {{{
6060
use {
6161
'gzagatti/nnn.nvim',
6262
branch = 'tweaks',
@@ -99,9 +99,8 @@ require'packer'.startup {function (use)
9999
"",
100100
"<f8>",
101101
":execute 'NnnExplorer' (expand('%:p') ==? expand('%:.') ? '%:p:h' : '')<cr>",
102-
{ noremap = true}
102+
{ noremap = true, silent = true }
103103
)
104-
vim.api.nvim_set_keymap("", "[telescope]/", "<cmd>NnnPicker %:p:h<cr>", { noremap = true })
105104
vim.cmd [[
106105
augroup nnn
107106
autocmd FileType * if &ft ==# "nnn" |:tnoremap <buffer> <f8> q| endif
@@ -215,10 +214,12 @@ require'packer'.startup {function (use)
215214
use {
216215
'Yggdroot/indentLine',
217216
config = function()
218-
vim.g.indentLine_defaultGroup = 'LineNr'
219-
vim.g['indentLine_concealcursor'] = 'nc'
220-
vim.g['indentLine_conceallevel'] = 2
217+
vim.g['indentLine_defaultGroup'] = 'IndentLine'
218+
vim.g['indentLine_concealcursor'] = 'c'
219+
vim.g['indentLine_conceallevel'] = 0
221220
vim.cmd [[
221+
autocmd ColorScheme leuven highlight IndentLine guifg='#dadad7' ctermfg=253'
222+
autocmd ColorScheme dracula highlight IndentLine guifg='#2f3751' ctermfg=253'
222223
autocmd TermOpen * IndentLinesDisable
223224
autocmd Filetype * if &ft ==# "help" | :IndentLinesDisable | endif
224225
autocmd Filetype * if &ft ==# "NeogitStatus" | :IndentLinesDisable | endif
@@ -247,12 +248,12 @@ require'packer'.startup {function (use)
247248
use {
248249
'gzagatti/vim-pencil',
249250
config = function ()
250-
vim.g['pencil#conceallevel'] = 2
251-
vim.g['pencil#concealcursor'] = 'nc'
251+
vim.g['pencil#conceallevel'] = 0
252+
vim.g['pencil#concealcursor'] = 'c'
252253
vim.cmd [[
253254
augroup pencil
254255
autocmd!
255-
autocmd FileType tex call pencil#init({'wrap': 'soft'})
256+
autocmd FileType tex,org call pencil#init({'wrap': 'soft'})
256257
augroup END
257258
]]
258259
end
@@ -264,21 +265,28 @@ require'packer'.startup {function (use)
264265
use {
265266
'junegunn/goyo.vim',
266267
config = function ()
268+
vim.g.goyo_width = "120"
269+
vim.g.goyo_height = "90%"
270+
vim.api.nvim_set_keymap('n', '<leader>go', '<cmd>Goyo<cr>', { noremap = true })
267271
vim.cmd [[
268272
function! s:GoyoEnter()
269-
silent !tmux set -w status off
270-
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
271-
nnoremap <f8> :NvimTreeToggle<cr>:Goyo x<cr>
273+
if executable('tmux') && strlen($TMUX)
274+
silent !tmux set -w status off
275+
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
276+
endif
277+
lua require('lualine').hide()
272278
autocmd VimResized * exe "normal \<c-w>="
273279
set noshowmode
274280
set noshowcmd
275281
endfunction
276282
277283
278284
function! s:GoyoLeave()
279-
silent !tmux set -w status on
280-
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
281-
nnoremap <f8> :NvimTreeToggle<cr>
285+
if executable('tmux') && strlen($TMUX)
286+
silent !tmux set -w status on
287+
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
288+
endif
289+
lua require('lualine').hide({unhide=true})
282290
set showmode
283291
set showcmd
284292
endfunction
@@ -290,6 +298,11 @@ require'packer'.startup {function (use)
290298
}
291299
---}}}
292300

301+
---easy align {{{
302+
-- vim alignment
303+
use { 'junegunn/vim-easy-align' }
304+
---}}}
305+
293306
---telescope {{{
294307
-- find, filter, preview, pick
295308
use {
@@ -310,6 +323,7 @@ require'packer'.startup {function (use)
310323
}
311324
vim.api.nvim_set_keymap('n', '[telescope]', '', { noremap = true })
312325
vim.api.nvim_set_keymap('n', '<space>', '[telescope]', {})
326+
vim.api.nvim_set_keymap('n', '[telescope]/', '<cmd>Telescope find_files theme=get_ivy<cr>', { noremap = true })
313327
vim.api.nvim_set_keymap('n', '[telescope]f', '<cmd>Telescope live_grep theme=get_ivy<cr>', { noremap = true })
314328
vim.api.nvim_set_keymap('n', '[telescope]y', '<cmd>Telescope registers theme=get_ivy<cr>', { noremap = true })
315329
vim.api.nvim_set_keymap('n', '[telescope]b', '<cmd>Telescope buffers theme=get_ivy<cr>', { noremap = true })
@@ -334,32 +348,23 @@ require'packer'.startup {function (use)
334348
org_do_demote = '>h',
335349
},
336350
},
337-
org_agenda_files = { vim.env.HOME .. '/dev/bstorm/**/*' },
338-
org_default_notes_file = vim.env.HOME .. '/dev/bstorm/inbox.org',
351+
org_agenda_files = {
352+
vim.env.HOME .. '/org/**/*',
353+
},
354+
org_default_notes_file = vim.env.HOME .. '/org/inbox.orgbundle/text.org',
339355
org_todo_keywords = {
340356
'TODO(t)', '|', 'POSTPONED(p)', 'CANCELLED(c)', 'DONE(d)'
341357
}
342358
}
343359
end,
344360
}
361+
---}}}
345362

346-
use {
347-
'akinsho/org-bullets.nvim',
348-
requires = { 'nvim-orgmode/orgmode' },
349-
config = function ()
350-
require("org-bullets").setup {
351-
concealcursor = true,
352-
symbols = {
353-
headlines = { "", "", "", "" },
354-
checkboxes = {
355-
half = {"-", "Normal"},
356-
done = { "x", "Normal" },
357-
todo = {" ", "Normal"},
358-
},
359-
},
360-
}
361-
end,
362-
}
363+
---org-goodies{{{
364+
use {
365+
here 'org-goodies.nvim',
366+
requires = { 'nvim-orgmode/orgmode' },
367+
}
363368
---}}}
364369

365370
---tablemode {{{
@@ -375,15 +380,14 @@ require'packer'.startup {function (use)
375380
'hrsh7th/nvim-cmp',
376381
requires = {
377382
'hrsh7th/cmp-nvim-lsp',
378-
'hrsh7th/cmp-buffer',
383+
-- 'hrsh7th/cmp-buffer',
379384
'hrsh7th/cmp-path',
380385
'hrsh7th/cmp-cmdline',
381386
'hrsh7th/vim-vsnip',
382387
'hrsh7th/cmp-vsnip',
383388
'kdheepak/cmp-latex-symbols',
384389
'hrsh7th/cmp-nvim-lua',
385390
'ray-x/cmp-treesitter',
386-
'ray-x/lsp_signature.nvim',
387391
},
388392
config = function ()
389393

@@ -435,7 +439,7 @@ require'packer'.startup {function (use)
435439
{ name = 'nvim_lsp' },
436440
{ name = 'vsnip' },
437441
{ name = 'latex_symbols' },
438-
{ name = 'buffer' },
442+
-- { name = 'buffer' },
439443
{ name = 'path' },
440444
{ name = 'orgmode' },
441445
{ name = 'nvim_lua' },
@@ -640,9 +644,6 @@ require'packer'.startup {function (use)
640644

641645
print("Attaching ", client.name, " LSP in buffer ", bufnr, "...")
642646

643-
local ok, lsp_signature = pcall(require, "lsp_signature")
644-
if ok then lsp_signature.on_attach() end
645-
646647
-- diagnostic
647648
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[telescope]l',
648649
'<cmd>Telescope diagnostics theme=get_ivy<cr>', opts)
@@ -867,6 +868,65 @@ require'packer'.startup {function (use)
867868
}
868869
---}}}
869870

871+
---hologram {{{
872+
-- image viewer for Neovim
873+
use {
874+
here 'hologram.nvim',
875+
config = function()
876+
require'hologram'.setup()
877+
end,
878+
}
879+
---}}}
880+
881+
---clipboard image {{{
882+
-- paste image from clipboard
883+
use {
884+
here 'clipboard-image.nvim',
885+
config = function()
886+
require'clipboard-image'.setup {
887+
default = {
888+
img_dir = {"%:p:h"},
889+
img_dir_txt = ".",
890+
},
891+
org = {
892+
img_dir = {"%:p:h", "assets"},
893+
img_dir_txt = "./assets",
894+
img_name = function()
895+
local img_dir = vim.fn.expand("%:p:h") .. "/assets"
896+
img_dir = io.popen('ls "'..img_dir..'" 2>/dev/null')
897+
local files = {}
898+
if img_dir ~= nil then
899+
for filename in img_dir:lines() do
900+
filename = filename:match("(.+)%..+$")
901+
if filename ~= nil then files[filename] = true end
902+
end
903+
img_dir.close()
904+
end
905+
repeat
906+
uuid = vim.fn.call("system", {"uuidgen"}):sub(10, 13)
907+
until files[uuid] == nil
908+
return uuid
909+
end,
910+
affix = "[[%s]]",
911+
img_size = "600x400",
912+
}
913+
}
914+
end,
915+
}
916+
--}}}
917+
918+
---nabla {{{
919+
-- equation rendering
920+
-- TODO support LaTex equations
921+
-- TODO support visual selection
922+
-- use {
923+
-- 'jbyuki/nabla.nvim',
924+
-- config = function()
925+
-- vim.api.nvim_set_keymap('n', '<leader>gE', "<cmd>lua require'nabla'.popup()<cr>", { noremap=true })
926+
-- end,
927+
-- }
928+
--}}}
929+
870930
---theme: dracula {{{
871931
use {
872932
'dracula/vim',
@@ -913,6 +973,11 @@ vim.opt.encoding = 'utf-8'
913973
vim.opt.lazyredraw = true
914974
---}}}
915975

976+
---colors {{{
977+
vim.opt.termguicolors = true
978+
vim.opt.guicursor = 'a:blinkon0-Cursor,i-ci:ver100'
979+
---}}}
980+
916981
---leaders {{{
917982
vim.g.mapleader = ';'
918983
vim.g.maplocalleader = '\\'
@@ -1048,11 +1113,6 @@ vim.g['loaded_ruby_provider'] = 0
10481113
vim.g['loaded_perl_provider'] = 0
10491114
---}}}
10501115

1051-
---colors {{{
1052-
vim.opt.termguicolors = true
1053-
vim.opt.guicursor = 'a:blinkon0-Cursor,i-ci:ver100'
1054-
---}}}
1055-
10561116
---terminal {{{
10571117
vim.api.nvim_set_keymap('t', '<c-h>', '<C-\\><C-N><C-w>h', { noremap = true })
10581118
vim.api.nvim_set_keymap('t', '<c-j>', '<C-\\><C-N><C-w>j', { noremap = true })
@@ -1167,11 +1227,11 @@ vim.cmd [[
11671227
11681228
nnoremap <expr> <silent> <buffer> l <SID>ForwardSkipConceal(v:count1)
11691229
nnoremap <expr> <silent> <buffer> h <SID>BackwardSkipConceal(v:count1)
1170-
nnoremap <expr> <leader>h <SID>ToggleConceal()
1230+
nnoremap <expr> <leader>hc <SID>ToggleConceal()
11711231
]]
11721232

1173-
vim.opt.conceallevel = 2
1174-
vim.opt.concealcursor = 'nc'
1233+
vim.opt.conceallevel = 0
1234+
vim.opt.concealcursor = 'c'
11751235
---}}}
11761236

11771237
---copy/paste mode toggle and shortcuts {{{

0 commit comments

Comments
 (0)