diff --git a/init.lua b/init.lua index 013fcc29..05fcea20 100644 --- a/init.lua +++ b/init.lua @@ -20,6 +20,10 @@ ===================================================================== ===================================================================== + + + + What is Kickstart? Kickstart.nvim is *not* a distribution. @@ -84,6 +88,28 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] +vim.api.nvim_set_keymap('n', 'Ø', ':E', { noremap = true, silent = true }) +-- command line height standard 1 +vim.opt.cmdheight = 1 + +-- Remap ø to in normal, visual, and operator-pending modes +vim.api.nvim_set_keymap('n', 'ø', '', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'ø', '', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('o', 'ø', '', { noremap = true, silent = true }) + +-- Remap ø to in insert mode +vim.api.nvim_set_keymap('i', 'ø', '', { noremap = true, silent = true }) + +-- Remap æ to in normal, visual, and operator-pending modes +vim.api.nvim_set_keymap('n', 'æ', '', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'æ', '', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('o', 'æ', '', { noremap = true, silent = true }) + +-- Remap æ to in insert mode +vim.api.nvim_set_keymap('i', 'æ', '', { noremap = true, silent = true }) + +-- remap shift æ to delete and fn æ to backspace + -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) @@ -102,7 +128,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = false -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -223,10 +249,27 @@ vim.opt.rtp:prepend(lazypath) -- To update plugins you can run -- :Lazy update -- + -- NOTE: Here is where you install your plugins. require('lazy').setup({ + + { + 'kylechui/nvim-surround', + version = '*', -- Use for stability; omit to use `main` branch for the latest features + event = 'VeryLazy', + config = function() + require('nvim-surround').setup { + -- Configuration here, or leave empty to use defaults + } + end, + }, -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + 'sainnhe/gruvbox-material', + -- 'segeljakt/vim-silicon', + + { 'numToStr/Comment.nvim', opts = {} }, + -- { 'tris203/precognition.nvim', opts = {} }, -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -236,10 +279,86 @@ require('lazy').setup({ -- -- This is equivalent to: -- require('Comment').setup({}) + { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local harpoon = require 'harpoon' + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + vim.keymap.set('n', 'a', function() + harpoon:list():add() + end) + vim.keymap.set('n', 'h', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + vim.keymap.set('n', '', function() + harpoon:list():select(1) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(2) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(3) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(4) + end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', '', function() + harpoon:list():prev() + end) + vim.keymap.set('n', '', function() + harpoon:list():next() + end) + local conf = require('telescope.config').values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require('telescope.pickers') + .new({}, { + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table { + results = file_paths, + }, + previewer = conf.file_previewer {}, + sorter = conf.generic_sorter {}, + }) + :find() + end + vim.keymap.set('n', '', function() + toggle_telescope(harpoon:list()) + end, { desc = 'Open harpoon window' }) + end, + }, -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, + -- better editing for directories/files etc + { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + -- Optional dependencies + dependencies = { { 'echasnovski/mini.icons', opts = {} } }, + config = function() + require('oil').setup() + vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) + end, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons + }, + -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. This is equivalent to the following Lua: -- require('gitsigns').setup({ ... }) @@ -539,8 +658,16 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, - -- pyright = {}, + gopls = {}, + pyright = {}, + html = {}, + intelephense = {}, + tsserver = {}, + cssls = {}, + vls = {}, + volar = { + filetypes = { 'vue' }, -- Use volar specifically for Vue files + }, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -614,6 +741,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + ocaml = { 'ocamlformat', 'ocp-indent' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -672,7 +800,11 @@ require('lazy').setup({ luasnip.lsp_expand(args.body) end, }, - completion = { completeopt = 'menu,menuone,noinsert' }, + completion = { + -- removes automatic autocomplete popup, just remove if regret(keep completeopt): + autocomplete = false, + completeopt = 'menu,menuone,noinsert', + }, -- For an understanding of why these mappings were -- chosen, you will need to read `:help ins-completion` @@ -730,18 +862,36 @@ require('lazy').setup({ }, { -- You can easily change to a different colorscheme. + -- This is where i config colorscheme / theme of nvim -- Change the name of the colorscheme plugin below, and then -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', + + 'catppuccin/nvim', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() + require('catppuccin').setup { + -- color_overrides = { + -- all = {}, + -- latte = { + -- base = '#ffffff', + -- mantle = '#000000', + -- crust = '#474747', + -- }, + -- }, + custom_highlights = function(colors) + return { + Comment = { fg = colors.pink }, + } + end, + } -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'catppuccin-latte' + -- vim.cmd.colorscheme 'rose-pine-dawn' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' end, @@ -763,7 +913,7 @@ require('lazy').setup({ -- Add/delete/replace surroundings (brackets, quotes, etc.) -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- - siw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').setup() @@ -791,7 +941,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc', 'css', 'javascript', 'ocaml' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -799,7 +949,7 @@ require('lazy').setup({ -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. -- If you are experiencing weird indenting issues, add the language to -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, + additional_vim_regex_highlighting = { 'ruby', 'ocaml' }, }, indent = { enable = true, disable = { 'ruby' } }, }, @@ -836,7 +986,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + -- { import = 'custom.plugins' } }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/kanban.lua b/lua/kanban.lua new file mode 100644 index 00000000..e40725d6 --- /dev/null +++ b/lua/kanban.lua @@ -0,0 +1,137 @@ +-- kanban.lua +local api = vim.api +local fn = vim.fn + +-- Create the kanban structure +local Kanban = { + boards = { + { + title = 'TODO', + tasks = {}, + }, + { + title = 'IN PROGRESS', + tasks = {}, + }, + { + title = 'DONE', + tasks = {}, + }, + }, + config_file = fn.stdpath 'data' .. '/kanban.json', +} + +-- Utility functions for JSON handling +local function encode_json(data) + return fn.json_encode(data) +end + +local function decode_json(str) + return fn.json_decode(str) +end + +-- Save kanban state to file +function Kanban:save() + local file = io.open(self.config_file, 'w') + if file then + file:write(encode_json(self.boards)) + file:close() + end +end + +-- Load kanban state from file +function Kanban:load() + local file = io.open(self.config_file, 'r') + if file then + local content = file:read '*all' + file:close() + self.boards = decode_json(content) + end +end + +-- Create a new task +function Kanban:add_task(board_idx, task) + if self.boards[board_idx] then + table.insert(self.boards[board_idx].tasks, task) + self:save() + self:render() + end +end + +-- Move task between boards +function Kanban:move_task(from_board, task_idx, to_board) + if self.boards[from_board] and self.boards[to_board] then + local task = table.remove(self.boards[from_board].tasks, task_idx) + if task then + table.insert(self.boards[to_board].tasks, task) + self:save() + self:render() + end + end +end + +-- Delete task +function Kanban:delete_task(board_idx, task_idx) + if self.boards[board_idx] then + table.remove(self.boards[board_idx].tasks, task_idx) + self:save() + self:render() + end +end + +-- Render the kanban board +function Kanban:render() + -- Clear buffer + api.nvim_buf_set_lines(0, 0, -1, false, {}) + + local lines = {} + local max_height = 0 + + -- Calculate maximum height + for _, board in ipairs(self.boards) do + local height = #board.tasks + 3 -- Title + border + tasks + if height > max_height then + max_height = height + end + end + + -- Create board headers + local headers = {} + local separators = {} + for _, board in ipairs(self.boards) do + table.insert(headers, '| ' .. board.title .. ' |') + table.insert(separators, string.rep('-', #board.title + 4)) + end + + -- Add headers + table.insert(lines, table.concat(headers, ' ')) + table.insert(lines, table.concat(separators, ' ')) + + -- Add tasks + for i = 1, max_height - 3 do + local row = {} + for b, board in ipairs(self.boards) do + local task = board.tasks[i] or '' + local width = #headers[b] - 2 + task = task .. string.rep(' ', width - #task) + table.insert(row, '|' .. task .. '|') + end + table.insert(lines, table.concat(row, ' ')) + end + + -- Set lines in buffer + api.nvim_buf_set_lines(0, 0, -1, false, lines) +end + +-- Commands +vim.cmd [[ + command! -nargs=1 KanbanAddTodo lua require'kanban':add_task(1, ) + command! -nargs=1 KanbanAddProgress lua require'kanban':add_task(2, ) + command! -nargs=1 KanbanAddDone lua require'kanban':add_task(3, ) + command! -nargs=+ KanbanMove lua require'kanban':move_task() + command! -nargs=+ KanbanDelete lua require'kanban':delete_task() + command! KanbanLoad lua require'kanban':load() + command! KanbanRender lua require'kanban':render() +]] + +return Kanban