From 98d8a599c6a2700b87a4eb9ef1e31299616e9c8f Mon Sep 17 00:00:00 2001 From: Jovan Djokic-Sumarac Date: Thu, 14 Aug 2025 08:02:26 +0200 Subject: [PATCH] add telekasten, telescope, new term handling --- lua/keymap.lua | 78 +++++++++++++++++++++++++++++++++----------------- lua/lsp.lua | 11 +------ lua/pack.lua | 13 ++++++--- lua/plug.lua | 45 ++++++++++++++++++----------- lua/term.lua | 50 ++++++++++++++++++++++++++++++++ 5 files changed, 139 insertions(+), 58 deletions(-) create mode 100644 lua/term.lua diff --git a/lua/keymap.lua b/lua/keymap.lua index 9b84585..5667e52 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -1,36 +1,60 @@ --- Normal mode mappings -vim.keymap.set('n', 'gd', vim.lsp.buf.hover, { noremap = true }) -vim.keymap.set('n', 'tw', function() MiniTrailspace.trim() end, { noremap = true }) +local term = require('term') --- Terminal and buffer mappings -vim.keymap.set('n', 'tt', 'terminal', { noremap = true }) -vim.keymap.set('t', '', '', { noremap = true }) -vim.keymap.set('n', '', 'bprev', { noremap = true }) +local keymaps = { + -- Normal mode mappings + { 'n', 'gd', vim.lsp.buf.hover, { noremap = true } }, + { 'n', 'tw', function() MiniTrailspace.trim() end, { noremap = true } }, --- Move selected text up/down in visual mode -vim.keymap.set('v', 'J', "m '>+1gv=gv", { noremap = true }) -vim.keymap.set('v', 'K', "m '<-2gv=gv", { noremap = true }) + -- Terminal and buffer mappings + { 'n', 'tt', term.toggle_popup_terminal, { noremap = true } }, + { 'n', 'th', term.toggle_popup_terminal, { noremap = true } }, + { 't', '', '', { noremap = true } }, + { 'n', '', 'bprev', { noremap = true } }, --- Keep cursor in the middle when jumping or joining lines -vim.keymap.set('n', 'J', 'mzJ`z', { noremap = true }) -vim.keymap.set('n', '', 'zz', { noremap = true }) -vim.keymap.set('n', '', 'zz', { noremap = true }) -vim.keymap.set('n', 'n', 'nzzzv', { noremap = true }) -vim.keymap.set('n', 'N', 'Nzzzv', { noremap = true }) + -- Move selected text up/down in visual mode + { 'v', 'J', "m '>+1gv=gv", { noremap = true } }, + { 'v', 'K', "m '<-2gv=gv", { noremap = true } }, + -- Keep cursor in the middle when jumping or joining lines + { 'n', 'J', 'mzJ`z', { noremap = true } }, + { 'n', '', 'zz', { noremap = true } }, + { 'n', '', 'zz', { noremap = true } }, + { 'n', 'n', 'nzzzv', { noremap = true } }, + { 'n', 'N', 'Nzzzv', { noremap = true } }, + -- Telescope mappings + { 'n', 'ff', 'Telescope find_files' }, + { 'n', 'fb', 'Telescope buffers' }, + { 'n', 'fh', 'Telescope help_tags' }, + { 'n', 'fg', 'Telescope live_grep' }, + { 'n', 'fs', 'Telescope git_status' }, + { 'n', 'ft', 'Telescope' }, -vim.keymap.set('n', 'ff', 'Pick files') -vim.keymap.set('n', 'fb', 'Pick buffers') -vim.keymap.set('n', 'h', 'Pick help') -vim.keymap.set('n', 'e', 'Oil') -vim.keymap.set('n', 'lf', vim.lsp.buf.format) + -- Telekasten mappings + { 'n', 'tk', 'Telekasten' }, + { 'n', 'tf', 'Telekasten find_notes' }, + { 'n', 'ts', 'Telekasten search_notes' }, + { 'n', 'tn', 'Telekasten new_note' }, + { 'n', 'tlf', 'Telekasten follow_link' }, + { 'n', 'tli', 'Telekasten insert_link' }, -vim.keymap.set('n', 'o', 'update source') -vim.keymap.set('n', 'w', 'write') -vim.keymap.set('n', 'q', 'quit') + -- File operations + { 'n', 'e', 'Oil' }, + { 'n', 'lf', vim.lsp.buf.format }, -vim.keymap.set({ 'n', 'v', 'x' }, 'y', "'+y") -vim.keymap.set({ 'n', 'v', 'x' }, 'd', "'+d") + -- Basic operations + { 'n', 'o', 'update source' }, + { 'n', 'w', 'write' }, + { 'n', 'q', 'quit' }, -vim.keymap.set('n', 'cc', 'ClaudeCode', { desc = 'Toggle Claude Code' }) + -- Copy/delete to system clipboard + { { 'n', 'v', 'x' }, 'y', "'+y" }, + { { 'n', 'v', 'x' }, 'd', "'+d" }, + + -- Claude Code + { 'n', 'cc', 'ClaudeCode', { desc = 'Toggle Claude Code' } }, +} + +for _, keymap in ipairs(keymaps) do + vim.keymap.set(keymap[1], keymap[2], keymap[3], keymap[4]) +end diff --git a/lua/lsp.lua b/lua/lsp.lua index 52d5250..215cf43 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,16 +1,9 @@ require('nvim-treesitter.configs').setup({ ensure_installed = { - 'c', 'bash', - 'c_sharp', - 'go', - 'haskell', 'lua', 'python', 'rust', - 'vim', - 'vimdoc', - 'hyprlang', }, sync_install = false, auto_install = true, @@ -34,7 +27,6 @@ require("mason-lspconfig").setup({ ensure_installed = { "lua_ls", "pylsp", - "ltex", }, automatic_installation = true, }) @@ -49,8 +41,7 @@ vim.lsp.config( 'lua_ls', { } } }) -vim.lsp.config( 'lua_ls', { }) -vim.lsp.enable({ 'lua_ls', 'pylsp' }) +vim.lsp.enable({ 'lua_ls', 'pylsp', 'csharp_ls' }) vim.diagnostic.config({ signs = false, diff --git a/lua/pack.lua b/lua/pack.lua index 8b47a12..ebc8e92 100644 --- a/lua/pack.lua +++ b/lua/pack.lua @@ -5,17 +5,22 @@ local function process_plugin(plugin) -- Handle when plugin is just a string (URL) if type(plugin) == "string" then - processed.url = plugin + processed.url = plugin:match("^https?://") and plugin or "https://github.com/" .. plugin return processed end -- Handle the plugin URL/name (convert from lazy.nvim format) + local url = nil if plugin[1] then - processed.url = plugin[1] + url = plugin[1] elseif plugin.url then - processed.url = plugin.url + url = plugin.url elseif plugin.src then - processed.url = plugin.src + url = plugin.src + end + + if url then + processed.url = url:match("^https?://") and url or "https://github.com/" .. url end -- Handle version diff --git a/lua/plug.lua b/lua/plug.lua index 5d8a22e..9ecd8b4 100644 --- a/lua/plug.lua +++ b/lua/plug.lua @@ -1,28 +1,39 @@ local pack = require 'pack' local plugins = { - 'https://github.com/catppuccin/nvim', - 'https://github.com/nvim-treesitter/nvim-treesitter', + 'catppuccin/nvim', + 'nvim-treesitter/nvim-treesitter', + { url = 'nvim-telescope/telescope.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + setup = true }, - { url = 'https://github.com/echasnovski/mini.cursorword', + { url = 'renerocksai/telekasten.nvim', + dependencies = { 'nvim-telescope/telescope.nvim' }, + setup = function() + require('telekasten').setup({ + home = vim.fn.expand("~/zettelkasten"), + }) + end }, + + { url = 'echasnovski/mini.cursorword', setup = true }, - { url = 'https://github.com/echasnovski/mini.pick', + { url = 'echasnovski/mini.pick', setup = true }, - { url = 'https://github.com/echasnovski/mini.starter', + { url = 'echasnovski/mini.starter', setup = true }, - { url = 'https://github.com/echasnovski/mini.trailspace', + { url = 'echasnovski/mini.trailspace', setup = true }, - { url = 'https://github.com/stevearc/oil.nvim', + { url = 'stevearc/oil.nvim', setup = true }, - { url = 'https://github.com/svampkorg/moody.nvim', + { url = 'svampkorg/moody.nvim', setup = true }, - { url = 'https://github.com/greggh/claude-code.nvim', + { url = 'greggh/claude-code.nvim', setup = function () require("claude-code").setup({ window = { @@ -39,8 +50,8 @@ local plugins = { }) end }, - { url = 'https://github.com/nvim-lualine/lualine.nvim', - dependencies = { 'https://github.com/nvim-tree/nvim-web-devicons' }, + { url = 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, setup = function () require('lualine').setup({ options = { @@ -50,16 +61,16 @@ local plugins = { }) end }, - { url = 'https://github.com/williamboman/mason.nvim', + { url = 'williamboman/mason.nvim', dependencies = { - { url = 'https://github.com/williamboman/mason-lspconfig.nvim', setup = true }, - 'https://github.com/neovim/nvim-lspconfig' + { url = 'williamboman/mason-lspconfig.nvim', setup = true }, + 'neovim/nvim-lspconfig' }, setup = true }, - { url = 'https://github.com/Saghen/blink.cmp', + { url = 'Saghen/blink.cmp', version = "v1.6.0", - dependencies = { 'https://github.com/rafamadriz/friendly-snippets' }}, + dependencies = { 'rafamadriz/friendly-snippets' }}, } pack.setup(plugins) @@ -101,7 +112,7 @@ local default_plugins = { } for _, plug in ipairs(default_plugins) do - vim.g['loaded_' .. plug] = 1 + vim.g['loaded_' .. plug] = 1 end diff --git a/lua/term.lua b/lua/term.lua new file mode 100644 index 0000000..f1ea579 --- /dev/null +++ b/lua/term.lua @@ -0,0 +1,50 @@ +local M = {} + +-- Popup terminal state +local popup_term = { + buf = nil, + win = nil, +} + +-- Function to create popup terminal +function M.toggle_popup_terminal() + if popup_term.win and vim.api.nvim_win_is_valid(popup_term.win) then + -- Close the popup if it's open + vim.api.nvim_win_close(popup_term.win, true) + popup_term.win = nil + else + -- Create or reuse terminal buffer + if not popup_term.buf or not vim.api.nvim_buf_is_valid(popup_term.buf) then + popup_term.buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_option(popup_term.buf, 'buftype', 'terminal') + end + + -- Calculate popup size + local width = math.floor(vim.o.columns * 0.8) + local height = math.floor(vim.o.lines * 0.8) + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + + -- Create floating window + popup_term.win = vim.api.nvim_open_win(popup_term.buf, true, { + relative = 'editor', + width = width, + height = height, + row = row, + col = col, + style = 'minimal', + border = 'rounded', + }) + + -- Start terminal if buffer is empty + if vim.api.nvim_buf_line_count(popup_term.buf) == 1 and + vim.api.nvim_buf_get_lines(popup_term.buf, 0, 1, false)[1] == '' then + vim.fn.termopen(vim.o.shell) + end + + -- Enter insert mode + vim.cmd('startinsert') + end +end + +return M