From bb542b005d3800cfc858565afdb57f57ae7bbd97 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Sat, 29 Jul 2023 20:58:33 +0200 Subject: [PATCH] feat: telekasten things --- home/neovim/default.nix | 4 ++ home/neovim/init.lua | 104 ++++++++++++++++++++++++++-------------- 2 files changed, 72 insertions(+), 36 deletions(-) diff --git a/home/neovim/default.nix b/home/neovim/default.nix index a3881c9..038818e 100644 --- a/home/neovim/default.nix +++ b/home/neovim/default.nix @@ -15,6 +15,7 @@ fd gcc hlint + chafa ltex-ls lua-language-server lua54Packages.luacheck @@ -36,4 +37,7 @@ extraLuaConfig = builtins.readFile ./init.lua; }; home.packages = [ pkgs.neovide ]; + home.file = { + notes.source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/Nextcloud/notes"; + }; } diff --git a/home/neovim/init.lua b/home/neovim/init.lua index 03183f2..76b1789 100644 --- a/home/neovim/init.lua +++ b/home/neovim/init.lua @@ -70,15 +70,18 @@ require("packer").startup(function(use) requires = { { 'nvim-lua/plenary.nvim' } } } use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } + use { 'nvim-lua/popup.nvim' } + use { 'nvim-telescope/telescope-media-files.nvim' } + use { + 'renerocksai/telekasten.nvim', + requires = { 'nvim-telescope/telescope.nvim' } + } + use { 'nvim-telescope/telescope-symbols.nvim' } + use { 'renerocksai/calendar-vim' } use("sheerun/vim-polyglot") use("nvim-treesitter/nvim-treesitter") - use("nvim-orgmode/orgmode") - use("akinsho/org-bullets.nvim") - use("lukas-reineke/headlines.nvim") - use("michaelb/sniprun") - use("dhruvasagar/vim-table-mode") end) vim.g.mapleader = "," @@ -147,6 +150,8 @@ nmap("", ":nohl") -- todo: try to do it with `vim.api.nvim_set_hl` vim.cmd("hi CursorLine cterm=NONE,underline ctermbg=NONE") -- highlight line when in insert mode +vim.cmd("hi tklink ctermfg=72 guifg=#689d6a cterm=bold,underline gui=bold,underline") +vim.cmd("hi tkBrackets ctermfg=gray guifg=gray") o.timeoutlen = 1000 o.ttimeoutlen = 0 @@ -201,7 +206,7 @@ augroup my-glyph-palette autocmd FileType nerdtree,startify call glyph_palette#apply() augroup END ]]) -nmap("tf", ":Fern . -drawer -toggle") +nmap("t", ":Fern . -drawer -toggle") nmap("", ": cd ..") vim.g["indentLine_char"] = "▏" @@ -343,37 +348,9 @@ cmp.setup { { name = 'luasnip' }, { name = 'buffer' }, { name = 'path' }, - { name = 'orgmode' }, }, } -local orgmode = require("orgmode") - -orgmode.setup_ts_grammar() -require("nvim-treesitter.configs").setup { - -- If TS highlights are not enabled at all, or disabled via `disable` prop, - -- highlighting will fallback to default Vim syntax highlighting - highlight = { - enable = true, - -- Required for spellcheck, some LaTex highlights and - -- code block highlights that do not have ts grammar - additional_vim_regex_highlighting = { "org" }, - }, - ensure_installed = { "org" }, -- Or run :TSUpdate org -} - -orgmode.setup { - org_agenda_files = { "~/Nextcloud/org/agenda/*.org" }, - org_default_notes_file = "~/Nextcloud/org/notes.org", - org_capture_templates = { - w = { - description = "Wishlist", - template = "* %x", - target = "~/Nextcloud/org/wishlist.org" - } - } -} - vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) @@ -418,12 +395,67 @@ telescope.setup { override_file_sorter = true, -- override the file sorter case_mode = "smart_case", -- or "ignore_case" or "respect_case" -- the default case_mode is "smart_case" - } + }, + -- media_files = { + -- -- filetypes whitelist + -- -- defaults to {"png", "jpg", "mp4", "webm", "pdf"} + -- filetypes = { "png", "webp", "jpg", "jpeg" }, + -- -- find command (defaults to `fd`) + -- find_cmd = "rg" + -- } } } telescope.load_extension("fzf") +telescope.load_extension("media_files") -require'nvim-web-devicons'.setup() +require 'nvim-web-devicons'.setup() + +local telekasten = require('telekasten') +telekasten.setup({ + home = vim.fn.expand("~/notes"), + daily = vim.fn.expand("~/notes/daily"), + weeklies = vim.fn.expand("~/notes/weeklies"), + templates = vim.fn.expand("~/notes/templates"), + + -- -- Specific note templates + -- -- set to `nil` or do not specify if you do not want a template + -- template_new_note = '/path/to/file', -- template for new notes + -- template_new_daily = '/path/to/file', -- template for new daily notes + -- template_new_weekly = '/path/to/file', -- template for new weekly notes + -- + image_subdir = "img", + extension = ".md", + + install_syntax = true, + media_previewer = "telescope-media-files", +}) + +vim.keymap.set("n", "z", telekasten.panel) + +vim.keymap.set("n", "zf", telekasten.find_notes) +vim.keymap.set("n", "zd", telekasten.find_daily_notes) +vim.keymap.set("n", "zg", telekasten.search_notes) +vim.keymap.set("n", "zz", telekasten.follow_link) +vim.keymap.set("n", "zT", telekasten.goto_today) +vim.keymap.set("n", "zW", telekasten.goto_thisweek) +vim.keymap.set("n", "zw", telekasten.find_weekly_notes) +vim.keymap.set("n", "zn", telekasten.new_note) +vim.keymap.set("n", "zN", telekasten.new_templated_note) +vim.keymap.set("n", "zy", telekasten.yank_notelink) +vim.keymap.set("n", "zc", telekasten.show_calendar) +vim.keymap.set("n", "zC", ":CalendarT") +vim.keymap.set("n", "zi", telekasten.paste_img_and_link) +vim.keymap.set("n", "zt", telekasten.toggle_todo) +vim.keymap.set("v", "zt", function() telekasten.toggle_todo({ v = true }) end) +vim.keymap.set("n", "zb", telekasten.show_backlinks) +vim.keymap.set("n", "zF", telekasten.find_friends) +vim.keymap.set("n", "zI", function() telekasten.insert_img_link({ i = true }) end) +vim.keymap.set("n", "zp", telekasten.preview_img) +vim.keymap.set("n", "zm", telekasten.browse_media) +vim.keymap.set("n", "#", telekasten.show_tags) +vim.keymap.set("i", "[[", function() telekasten.insert_link({ i = true }) end) +vim.keymap.set("i", "zt", function() telekasten.toggle_todo({ i = true }) end) +vim.keymap.set("i", "#", function() telekasten.show_tags({ i = true }) end) if vim.g.neovide then vim.o.guifont = "Hack Nerd Font:h10"