diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index 8b4990f..ca2746f 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -357,7 +357,7 @@ function M.highlight() -- Load highlight groups local async - async = vim.loop.new_async(vim.schedule_wrap(function () + async = vim.loop.new_async(vim.schedule_wrap(function() set_vim_termcolors() highlight_plugins() highlight_treesitter() diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index abd44c8..33585be 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -123,6 +123,8 @@ wk.register({ name = 'Buffer', c = {':ColorizerToggle', 'Colorizer'}, d = {':bdelete', 'Close buffer'}, + j = {':BufferLineCyclePrev', 'Previous buffer'}, + k = {':BufferLineCycleNext', 'Previous buffer'}, n = {':DashboardNewFile', 'New file'}, z = {':ZenMode', 'Zen mode'} }, @@ -173,6 +175,15 @@ wk.register({ } }, + -- translate-shell.vim + j = { + name = 'Translate', + t = {':Trans', 'Translate'}, + d = {':TransSelectDirection', 'Translate with direction'}, + r = {'cw=system(\'trans -brief -no-ansi\', getreg(""))[:-2]', 'Translate and replace'}, + c = {'cw=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]', 'Translate and replace with direction'} + }, + l = { name = 'LSP', a = 'Add workspace folder', @@ -207,13 +218,20 @@ wk.register({ n = {':NnnPicker %:p:h', 'File picker'}, + -- orgmode.nvim + o = { + name = 'Org', + a = 'Agenda', + c = 'Capture' + }, + -- Tab related t = { name = 'Tab', c = {'tabclose', 'Close tab'}, - n = {'tabnext', 'Next tab'}, - p = {'tabprev', 'Previous tab'}, - t = {'tabnew', 'New tab'} + j = {'tabprev', 'Previous tab'}, + k = {'tabnext', 'Next tab'}, + n = {'tabnew', 'New tab'} } }, {prefix = ''}) @@ -226,5 +244,75 @@ wk.register({ name = 'Git', r = 'Reset hunk', s = 'Stage hunk' + }, + + -- translate-shell.vim + j = { + name = 'Translate', + t = {':Trans', 'Translate'}, + d = {':TransSelectDirection', 'Translate with direction'}, + r = {'c=system(\'trans -brief -no-ansi\', getreg(""))[:-2]', 'Translate and replace'}, + c = {'c=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]', 'Translate and replace with direction'} } }, {mode = 'v', prefix = ''}) + +------------------------ +-- Filetype specified -- +------------------------ +vim.cmd(([[ +autocmd FileType org lua whichkeyOrg() +autocmd FileType markdown lua whichkeyMarkdown() +autocmd FileType html lua whichkeyHtml() +]])) + +_G.whichkeyOrg = function() + wk.register({ + ['o'] = { + A = 'Toggle ARCHIVE', + e = 'Export', + i = { + name = 'Insert', + h = 'Add headline', + t = 'Add TODO heading and content', + T = 'Add TODO heading', + }, + J = 'Move subtree down', + K = 'Move subtree up', + o = 'Open at point', + r = 'Refile', + t = 'Set tags', + ['$'] = 'Archive current headline' + }, + [''] = 'Org meta return', + [''] = 'Org increase date', + [''] = 'Org decrease date', + ['cid'] = 'Org change date', + ['cit'] = 'Org TODO', + ['ciT'] = 'Org TODO prev', + [''] = 'Org toggle checkbox', + [''] = 'Org cycle folding', + [''] = 'Org cycle global folding', + ['<<'] = 'Org promote headline', + ['>>'] = 'Org demote headline', + ['s'] = 'Org demote subtree', + ['}'] = 'Org next visible heading', + ['{'] = 'Org previous visible heading', + [']]'] = 'Org forward heading', + ['[['] = 'Org backward heading', + ['g{'] = 'Org parent heading', + ['?'] = 'Org help' + }) +end + +_G.whichkeyMarkdown = function() + wk.register({ + ['bp'] = {':MarkdownPreviewToggle', 'Preview markdown'} + }) +end + +_G.whichkeyHtml = function() + wk.register({ + ['bp'] = {':Bracey', 'Preview html'} + }) +end diff --git a/home/.config/nvim/lua/modules/completion.lua b/home/.config/nvim/lua/modules/completion.lua index d5b1476..284b938 100644 --- a/home/.config/nvim/lua/modules/completion.lua +++ b/home/.config/nvim/lua/modules/completion.lua @@ -5,6 +5,7 @@ require('compe').setup { min_length = 1, preselect = 'always', source = { + orgmode = true, path = true, buffer = true, calc = false, diff --git a/home/.config/nvim/lua/modules/org.lua b/home/.config/nvim/lua/modules/org.lua new file mode 100644 index 0000000..135f24d --- /dev/null +++ b/home/.config/nvim/lua/modules/org.lua @@ -0,0 +1,39 @@ +local c = require('colors.' .. vim.g.global_theme).colors + +return require('orgmode').setup({ + -- General settings + org_agenda_files = { + '~/Documents/Org/agenda/agenda.org', + '~/Documents/Org/agenda/archive.org' + }, + org_default_notes_file = '~/Documents/Org/notes.org', + org_todo_keywords = { + 'TODO', 'PROJ', 'LOOP', 'STRT', 'WAIT', 'HOLD', 'IDEA', 'DONE', 'KILL', + '[ ]', '[-]', '[X]' , '|', 'OKAY', 'YES', 'NO' + }, + org_todo_keyword_faces = { + TODO = ':foreground ' .. c.green .. ' :weight bold', + PROJ = ':foreground ' .. c.grey_bright .. ' :weight bold :slant italic', + LOOP = ':foreground ' .. c.green .. ' :weight bold :underline on', + STRT = ':foreground ' .. c.blue .. ' :weight bold', + WAIT = ':foreground ' .. c.yellow .. ' :weight bold', + HOLD = ':foreground ' .. c.yellow .. ' :weight bold :slant italic', + IDEA = ':foreground ' .. c.green .. ' :weight bold :slant italic', + DONE = ':foreground ' .. c.grey2 .. ' :weight bold', + KILL = ':foreground ' .. c.red .. ' :weight bold', + OKAY = ':foreground ' .. c.grey1 .. ' :weight bold :slant italic', + YES = ':foreground ' .. c.grey1 .. ' :weight bold :underline on', + NO = ':foreground ' .. c.red .. ' :weight bold :underline on' + }, + org_hide_leading_stars = true, + org_highlight_latex_and_related = 'entities', + + -- Agenda settings + org_deadline_warning_days = 7, + org_agenda_span = 'week', + org_agenda_start_on_weekday = 7, -- Start a week in Sunday + org_agenda_min_height = 15, + + -- Tags settings + org_use_tag_inheritance = false +}) diff --git a/home/.config/nvim/lua/modules/picker.lua b/home/.config/nvim/lua/modules/picker.lua index af5f53a..b879200 100644 --- a/home/.config/nvim/lua/modules/picker.lua +++ b/home/.config/nvim/lua/modules/picker.lua @@ -2,7 +2,7 @@ return require('nnn').setup { set_default_mappings = false, session = 'global', layout = { - window = { width = 0.8, height = 0.8, highlight = 'Debug' }, + window = {width = 0.8, height = 0.8, highlight = 'Debug'}, }, command = 'nnn -HUdex', action = { diff --git a/home/.config/nvim/lua/modules/translate-shell.lua b/home/.config/nvim/lua/modules/translate-shell.lua new file mode 100644 index 0000000..8142eb5 --- /dev/null +++ b/home/.config/nvim/lua/modules/translate-shell.lua @@ -0,0 +1,18 @@ +local function translate_options() + vim.g.trans_join_lines = 1 + vim.g.trans_win_height = 15 + vim.g.trans_default_direction = ':ja' + vim.g.trans_directions_list = { + {'', 'en'}, + {'', 'ja'}, + {'', 'de'}, + {'', 'ru'}, + {'', 'fr'}, + {'', 'nl'}, + {'', 'es'}, + {'', 'zh-CN'}, + {'', 'zh-TW'} + } +end + +translate_options() diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 94da71a..63a7628 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -321,6 +321,19 @@ return require('packer').startup( require('modules.zen') end } + use { + 'kristijanhusak/orgmode.nvim', -- shouldn't be lazy-loaded (otherwise keybindings don't work) + config = function() + require('modules.org') + end + } + use { + 'echuraev/translate-shell.vim', + cmd = {'Trans', 'TransSelectDirection'}, + config = function() + require('modules.translate-shell') + end + } use { 'akinsho/nvim-toggleterm.lua', cmd = 'ToggleTerm', @@ -339,7 +352,7 @@ return require('packer').startup( end } - -- TODO: lspsaga, orgmode.nvim, nvim-lint, format(ter).nvim, rest.nvim, sqls.nvim, + -- TODO: lspsaga, nvim-lint, format(ter).nvim, rest.nvim, sqls.nvim, -- nvim-spectre, nvim-dap, dial.nvim, asynctasks.nvim end )