From c4aabd2da3ce39fff10cf743d0803b2cc1bb263e Mon Sep 17 00:00:00 2001 From: BearDad Date: Wed, 20 Nov 2024 18:44:50 +0100 Subject: [PATCH 1/8] setting up --- init.lua | 206 +++++++++++++++++++++++++++--- lazyvim.json | 9 ++ lua/config/lazy.lua | 15 +++ lua/custom/plugins/dashboard.lua | 18 +++ lua/custom/plugins/emoji.lua | 1 + lua/custom/plugins/gitflog.lua | 8 ++ lua/custom/plugins/gitgraph.lua | 32 +++++ lua/custom/plugins/inc-rename.lua | 5 + lua/custom/plugins/nerdicons.lua | 7 + lua/custom/plugins/noice.lua | 7 + lua/custom/plugins/oil.lua | 60 +++++++++ lua/custom/plugins/plugins.lua | 9 ++ lua/custom/plugins/rose-pine.lua | 1 + lua/custom/plugins/snacks.lua | 154 ++++++++++++++++++++++ lua/custom/plugins/supermaven.lua | 8 ++ lua/custom/plugins/tmux-vim.lua | 17 +++ lua/custom/plugins/vimtex.lua | 32 +++++ lua/custom/plugins/wakatime.lua | 1 + 18 files changed, 569 insertions(+), 21 deletions(-) create mode 100644 lazyvim.json create mode 100644 lua/config/lazy.lua create mode 100644 lua/custom/plugins/dashboard.lua create mode 100755 lua/custom/plugins/emoji.lua create mode 100644 lua/custom/plugins/gitflog.lua create mode 100644 lua/custom/plugins/gitgraph.lua create mode 100644 lua/custom/plugins/inc-rename.lua create mode 100644 lua/custom/plugins/nerdicons.lua create mode 100644 lua/custom/plugins/noice.lua create mode 100644 lua/custom/plugins/oil.lua create mode 100755 lua/custom/plugins/plugins.lua create mode 100644 lua/custom/plugins/rose-pine.lua create mode 100644 lua/custom/plugins/snacks.lua create mode 100644 lua/custom/plugins/supermaven.lua create mode 100755 lua/custom/plugins/tmux-vim.lua create mode 100644 lua/custom/plugins/vimtex.lua create mode 100644 lua/custom/plugins/wakatime.lua diff --git a/init.lua b/init.lua index 4ce35f4b5c4..cc67ad5cfe9 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,14 +102,13 @@ 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 = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' -- Don't show the mode, since it's already in the status line vim.opt.showmode = false - -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. @@ -129,7 +128,7 @@ vim.opt.ignorecase = true vim.opt.smartcase = true -- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' +vim.opt.signcolumn = 'auto' -- Decrease update time vim.opt.updatetime = 250 @@ -155,7 +154,7 @@ vim.opt.inccommand = 'split' vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 +vim.opt.scrolloff = 15 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -176,10 +175,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows @@ -255,7 +254,6 @@ require('lazy').setup({ }, }, }, - -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- -- This is often very useful to both group configuration, as well as handle @@ -270,7 +268,6 @@ require('lazy').setup({ -- Then, because we use the `config` key, the configuration only runs -- after the plugin has been loaded: -- config = function() ... end - { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' @@ -870,14 +867,12 @@ require('lazy').setup({ -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. + require('mini.surround').setup() -- Simple and easy statusline. -- You could remove this setup call if you don't like it, -- and try some other statusline plugin local statusline = require 'mini.statusline' -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } + statusline.setup { use_icons = true } -- You can configure sections in the statusline by overriding their -- default behavior. For example, here we set the section for @@ -891,6 +886,54 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, + { + 'saghen/blink.cmp', + lazy = false, -- lazy loading handled internally + -- optional: provides snippets for the snippet source + dependencies = 'rafamadriz/friendly-snippets', + + -- use a release tag to download pre-built binaries + version = 'v0.*', + -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- If you use nix, you can build from source using latest nightly rust with: + -- build = 'nix run .#build-plugin', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' for mappings similar to built-in completion + -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate) + -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept + -- see the "default configuration" section below for full documentation on how to define + -- your own keymap. when defining your own, no keybinds will be assigned automatically. + keymap = 'enter', + + highlight = { + -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- useful for when your theme doesn't support blink.cmp + -- will be removed in a future release, assuming themes add support + use_nvim_cmp_as_default = true, + }, + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- adjusts spacing to ensure icons are aligned + nerd_font_variant = 'normal', + + -- experimental auto-brackets support + -- accept = { auto_brackets = { enabled = true } } + + -- experimental signature help support + -- trigger = { signature_help = { enabled = true } } + }, + }, + + -- LSP servers and clients communicate what features they support through "capabilities". + -- By default, Neovim support a subset of the LSP specification. + -- With blink.cmp, Neovim has *more* capabilities which are communicated to the LSP servers. + -- Explanation from TJ: https://youtu.be/m8C0Cq9Uv9o?t=1275 + -- + -- This can vary by config, but in-general for nvim-lspconfig: + { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', @@ -926,18 +969,18 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -967,3 +1010,124 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +-- +-- NOTE: THIS IS ROSEPINE CONFIG +-- +require('rose-pine').setup { + variant = 'main', -- auto, main, moon, or dawn + dark_variant = 'main', -- main, moon, or dawn + dim_inactive_windows = false, + extend_background_behind_borders = true, + + enable = { + terminal = true, + legacy_highlights = true, -- Improve compatibility for previous versions of Neovim + migrations = true, -- Handle deprecated options automatically + }, + + styles = { + bold = true, + italic = true, + transparency = true, + }, + + groups = { + border = 'muted', + link = 'iris', + panel = 'surface', + + error = 'love', + hint = 'iris', + info = 'foam', + note = 'pine', + todo = 'rose', + warn = 'gold', + + git_add = 'foam', + git_change = 'rose', + git_delete = 'love', + git_dirty = 'rose', + git_ignore = 'muted', + git_merge = 'iris', + git_rename = 'pine', + git_stage = 'iris', + git_text = 'rose', + git_untracked = 'subtle', + + h1 = 'iris', + h2 = 'foam', + h3 = 'rose', + h4 = 'gold', + h5 = 'pine', + h6 = 'foam', + }, + + palette = { + -- Override the builtin palette per variant + moon = { + base = '#18191a', + overlay = '#363738', + }, + }, + + highlight_groups = { + Comment = { fg = 'foam' }, + VertSplit = { fg = 'muted', bg = 'muted' }, + }, + + before_highlight = function(group, highlight, palette) + -- Disable all undercurls + -- if highlight.undercurl then + -- highlight.undercurl = false + -- end + -- + -- Change palette colour + -- if highlight.fg == palette.pine then + -- highlight.fg = palette.foam + -- end + end, +} + +vim.cmd 'colorscheme rose-pine' +-- vim.cmd("colorscheme rose-pine-main") +-- vim.cmd("colorscheme rose-pine-moon") +-- vim.cmd("colorscheme rose-pine-dawn") +-- +-- +-- +-- +-- +-- NOTE: This are my personal keybinds +-- +vim.g.vimtex_view_method = '' +vim.g.vimtex_compiler_method = 'latexmk' +vim.opt.guicursor = 'a:block' + +vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move down' }) +vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move up' }) + +vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }) +vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }) +vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { desc = 'Paste from system clipboard' }) +vim.keymap.set({ 'v', 'n' }, 't', 'TSBufToggle highlight', { desc = 'Toggle Tree-sitter highlighting' }) +vim.keymap.set('n', 'z', ":!zathura =expand('%:r').pdf &", { desc = 'Open PDF' }) + +vim.keymap.set({ 'n' }, 'p', function() + local file_name = vim.fn.expand '%:t' + if file_name ~= '' then + -- Open Explorer in the current directory and select the file + vim.fn.system { 'explorer.exe', '/select,', file_name } + else + print 'No file name found. Save the buffer first.' + end +end, { desc = 'Open file location in Explorer' }) + +vim.keymap.set({ 'n' }, 'o', function() + local file_name = vim.fn.expand '%:t' + if file_name ~= '' then + -- Open Explorer in the current directory and select the file + vim.fn.system { 'explorer.exe', file_name } + else + print 'No file found. Make sure the buffer is saved.' + end +end, { desc = 'Open file ' }) diff --git a/lazyvim.json b/lazyvim.json new file mode 100644 index 00000000000..7fd2a72064a --- /dev/null +++ b/lazyvim.json @@ -0,0 +1,9 @@ +{ + "extras": [ + + ], + "news": { + "NEWS.md": "7429" + }, + "version": 7 +} \ No newline at end of file diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 00000000000..1335e431486 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,15 @@ +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { 'Failed to clone lazy.nvim:\n', 'ErrorMsg' }, + { out, 'WarningMsg' }, + { '\nPress any key to exit...' }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) diff --git a/lua/custom/plugins/dashboard.lua b/lua/custom/plugins/dashboard.lua new file mode 100644 index 00000000000..3061293bde5 --- /dev/null +++ b/lua/custom/plugins/dashboard.lua @@ -0,0 +1,18 @@ +return { + 'nvimdev/dashboard-nvim', + event = 'VimEnter', + theme = 'hyper', + config = function() + require('dashboard').setup { + -- config + -- + } + end, + hide = { + statusline, -- hide statusline default is true + tabline, -- hide the tabline + winbar, -- hide winbar + }, + + dependencies = { { 'nvim-tree/nvim-web-devicons' } }, +} diff --git a/lua/custom/plugins/emoji.lua b/lua/custom/plugins/emoji.lua new file mode 100755 index 00000000000..b96a0a551d5 --- /dev/null +++ b/lua/custom/plugins/emoji.lua @@ -0,0 +1 @@ +return { "xiyaowong/telescope-emoji" } diff --git a/lua/custom/plugins/gitflog.lua b/lua/custom/plugins/gitflog.lua new file mode 100644 index 00000000000..0e815c23545 --- /dev/null +++ b/lua/custom/plugins/gitflog.lua @@ -0,0 +1,8 @@ +return { + "rbong/vim-flog", + lazy = true, + cmd = { "Flog", "Flogsplit", "Floggit" }, + dependencies = { + "tpope/vim-fugitive", + }, +} diff --git a/lua/custom/plugins/gitgraph.lua b/lua/custom/plugins/gitgraph.lua new file mode 100644 index 00000000000..5fb4d6bc16e --- /dev/null +++ b/lua/custom/plugins/gitgraph.lua @@ -0,0 +1,32 @@ +return { + 'isakbm/gitgraph.nvim', + ---@type I.GGConfig + opts = { + symbols = { + merge_commit = 'M', + commit = '*', + + }, + format = { + timestamp = '%H:%M:%S %d-%m-%Y', + fields = { 'hash', 'timestamp', 'author', 'branch_name', 'tag' }, + }, + hooks = { + on_select_commit = function(commit) + print('selected commit:', commit.hash) + end, + on_select_range_commit = function(from, to) + print('selected range:', from.hash, to.hash) + end, + }, + }, + keys = { + { + "gl", + function() + require('gitgraph').draw({}, { all = true, max_count = 5000 }) + end, + desc = "GitGraph - Draw", + }, + }, +} diff --git a/lua/custom/plugins/inc-rename.lua b/lua/custom/plugins/inc-rename.lua new file mode 100644 index 00000000000..77bf4f9cab9 --- /dev/null +++ b/lua/custom/plugins/inc-rename.lua @@ -0,0 +1,5 @@ +return { + 'smjonas/inc-rename.nvim', + cmd = 'IncRename', + opts = {}, +} diff --git a/lua/custom/plugins/nerdicons.lua b/lua/custom/plugins/nerdicons.lua new file mode 100644 index 00000000000..6e9b7a2b384 --- /dev/null +++ b/lua/custom/plugins/nerdicons.lua @@ -0,0 +1,7 @@ +return { + "glepnir/nerdicons.nvim", + cmd = "NerdIcons", + config = function() + require("nerdicons").setup({}) + end, +} diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua new file mode 100644 index 00000000000..c4245ef75e9 --- /dev/null +++ b/lua/custom/plugins/noice.lua @@ -0,0 +1,7 @@ +return { + 'folke/noice.nvim', + optional = true, + opts = { + presets = { inc_rename = true }, + }, +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 00000000000..ace20dcc0f8 --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,60 @@ +return { + "stevearc/oil.nvim", + config = function() + local oil = require("oil") + oil.setup({ + buf_options = { + buflisted = false, + bufhidden = "hide", + }, + + skip_confirm_for_simple_edits = true, + + view_options = { + -- Show files and directories that start with "." + show_hidden = true, + -- This function defines what is considered a "hidden" file + is_hidden_file = function(name, bufnr) + return vim.startswith(name, ".") + end, + -- This function defines what will never be shown, even when `show_hidden` is set + is_always_hidden = function(name, bufnr) + return false + end, + -- Sort file names in a more intuitive order for humans. Is less performant, + -- so you may want to set to false if you work with large directories. + natural_order = true, + -- Sort file and directory names case insensitive + case_insensitive = false, + sort = { + -- sort order can be "asc" or "desc" + -- see :help oil-columns to see which columns are sortable + { "type", "asc" }, + { "name", "asc" }, + }, + }, + float = { + -- Padding around the floating window + padding = 4, + max_width = 100, + max_height = 15, + border = "rounded", + win_options = { + winblend = 0, + }, + -- optionally override the oil buffers window title with custom function: fun(winid: integer): string + get_win_title = nil, + -- preview_split: Split direction: "auto", "left", "right", "above", "below". + preview_split = "auto", + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + override = function(conf) + return conf + end, + }, + }) + + vim.keymap.set("n", "-", "Oil", { desc = "Open oil" }) + vim.keymap.set("n", "-", oil.toggle_float, {}) + end, +} diff --git a/lua/custom/plugins/plugins.lua b/lua/custom/plugins/plugins.lua new file mode 100755 index 00000000000..0f84ddf79e2 --- /dev/null +++ b/lua/custom/plugins/plugins.lua @@ -0,0 +1,9 @@ +return { + "stevearc/aerial.nvim", + opts = {}, + -- Optional dependencies + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons", + }, +} diff --git a/lua/custom/plugins/rose-pine.lua b/lua/custom/plugins/rose-pine.lua new file mode 100644 index 00000000000..28b2599d6d7 --- /dev/null +++ b/lua/custom/plugins/rose-pine.lua @@ -0,0 +1 @@ +return { "rose-pine/neovim", name = "rose-pine" } diff --git a/lua/custom/plugins/snacks.lua b/lua/custom/plugins/snacks.lua new file mode 100644 index 00000000000..e84da36d5f9 --- /dev/null +++ b/lua/custom/plugins/snacks.lua @@ -0,0 +1,154 @@ +return { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + bigfile = { enabled = true }, + dashboard = { enabled = true }, + notifier = { + enabled = true, + timeout = 3000, + }, + quickfile = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + styles = { + notification = { + wo = { wrap = true }, -- Wrap notifications + }, + }, + }, + keys = { + { + 'un', + function() + Snacks.notifier.hide() + end, + desc = 'Dismiss All Notifications', + }, + { + 'bd', + function() + Snacks.bufdelete() + end, + desc = 'Delete Buffer', + }, + { + 'gg', + function() + Snacks.lazygit() + end, + desc = 'Lazygit', + }, + { + 'gb', + function() + Snacks.git.blame_line() + end, + desc = 'Git Blame Line', + }, + { + 'gB', + function() + Snacks.gitbrowse() + end, + desc = 'Git Browse', + }, + { + 'gf', + function() + Snacks.lazygit.log_file() + end, + desc = 'Lazygit Current File History', + }, + { + 'gl', + function() + Snacks.lazygit.log() + end, + desc = 'Lazygit Log (cwd)', + }, + { + 'cR', + function() + Snacks.rename.rename_file() + end, + desc = 'Rename File', + }, + { + '', + function() + Snacks.terminal() + end, + desc = 'Toggle Terminal', + }, + { + '', + function() + Snacks.terminal() + end, + desc = 'which_key_ignore', + }, + { + ']]', + function() + Snacks.words.jump(vim.v.count1) + end, + desc = 'Next Reference', + mode = { 'n', 't' }, + }, + { + '[[', + function() + Snacks.words.jump(-vim.v.count1) + end, + desc = 'Prev Reference', + mode = { 'n', 't' }, + }, + { + 'N', + desc = 'Neovim News', + function() + Snacks.win { + file = vim.api.nvim_get_runtime_file('doc/news.txt', false)[1], + width = 0.6, + height = 0.6, + wo = { + spell = false, + wrap = false, + signcolumn = 'yes', + statuscolumn = ' ', + conceallevel = 3, + }, + } + end, + }, + }, + init = function() + vim.api.nvim_create_autocmd('User', { + pattern = 'VeryLazy', + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + vim.print = _G.dd -- Override print to use snacks for `:=` command + + -- Create some toggle mappings + Snacks.toggle.option('spell', { name = 'Spelling' }):map 'us' + Snacks.toggle.option('wrap', { name = 'Wrap' }):map 'uw' + Snacks.toggle.option('relativenumber', { name = 'Relative Number' }):map 'uL' + Snacks.toggle.diagnostics():map 'ud' + Snacks.toggle.line_number():map 'ul' + Snacks.toggle.option('conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map 'uc' + Snacks.toggle.treesitter():map 'uT' + Snacks.toggle.option('background', { off = 'light', on = 'dark', name = 'Dark Background' }):map 'ub' + Snacks.toggle.inlay_hints():map 'uh' + end, + }) + end, +} diff --git a/lua/custom/plugins/supermaven.lua b/lua/custom/plugins/supermaven.lua new file mode 100644 index 00000000000..cf8813470f1 --- /dev/null +++ b/lua/custom/plugins/supermaven.lua @@ -0,0 +1,8 @@ +return { + { + "supermaven-inc/supermaven-nvim", + config = function() + require("supermaven-nvim").setup({}) + end, + }, +} diff --git a/lua/custom/plugins/tmux-vim.lua b/lua/custom/plugins/tmux-vim.lua new file mode 100755 index 00000000000..4421fed9a43 --- /dev/null +++ b/lua/custom/plugins/tmux-vim.lua @@ -0,0 +1,17 @@ +return { + "christoomey/vim-tmux-navigator", + cmd = { + "TmuxNavigateLeft", + "TmuxNavigateDown", + "TmuxNavigateUp", + "TmuxNavigateRight", + "TmuxNavigatePrevious", + }, + keys = { + { "", "TmuxNavigateLeft" }, + { "", "TmuxNavigateDown" }, + { "", "TmuxNavigateUp" }, + { "", "TmuxNavigateRight" }, + { "", "TmuxNavigatePrevious" }, + }, +} diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua new file mode 100644 index 00000000000..d246d642256 --- /dev/null +++ b/lua/custom/plugins/vimtex.lua @@ -0,0 +1,32 @@ +return { + { + "lervag/vimtex", + lazy = false, -- we don't want to lazy load VimTeX + -- tag = "v2.15", -- uncomment to pin to a specific release + init = function() + -- VimTeX configuration goes here, e.g. + vim.g.vimtex_view_general_viewer = "" + vim.g.vimtex_view_general_options = "" + vim.g.vimtex_view_method = "" + vim.g.vimtex_compiler_method = "latexmk" + vim.g.vimtex_view_general_options = '--unique file:@pdf""#src:@line@tex' + vim.g.tex_conceal = "abdmg" + vim.g.tex_flavor = "latex" + vim.g.vimtex_syntax_conceal = { + accents = true, + ligatures = true, + cites = true, + fancy = true, + spacing = true, + greek = true, + math_bounds = true, + math_delimiters = true, + math_fracs = true, + math_super_sub = true, + math_symbols = true, + sections = true, + styles = true, + } + end, + }, +} diff --git a/lua/custom/plugins/wakatime.lua b/lua/custom/plugins/wakatime.lua new file mode 100644 index 00000000000..e151fc34cb4 --- /dev/null +++ b/lua/custom/plugins/wakatime.lua @@ -0,0 +1 @@ +return { "wakatime/vim-wakatime", lazy = false } From 271f3fbc2ff3aa6cd5732f428968750233375089 Mon Sep 17 00:00:00 2001 From: BearDad Date: Wed, 20 Nov 2024 18:45:09 +0100 Subject: [PATCH 2/8] setting up --- init.lua | 48 ++++++++++++++++++++++++++++++++--- lua/custom/keybinds/binds.lua | 34 +++++++++++++++++++++++++ lua/custom/plugins/snacks.lua | 2 +- 3 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 lua/custom/keybinds/binds.lua diff --git a/init.lua b/init.lua index cc67ad5cfe9..04617bbb733 100644 --- a/init.lua +++ b/init.lua @@ -981,6 +981,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. { import = 'custom.plugins' }, + -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -1103,9 +1104,6 @@ vim.g.vimtex_view_method = '' vim.g.vimtex_compiler_method = 'latexmk' vim.opt.guicursor = 'a:block' -vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move down' }) -vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move up' }) - vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }) vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }) vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { desc = 'Paste from system clipboard' }) @@ -1131,3 +1129,47 @@ vim.keymap.set({ 'n' }, 'o', function() print 'No file found. Make sure the buffer is saved.' end end, { desc = 'Open file ' }) + +-- NOTE: THESE ARE FROM https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua + +vim.keymap.set({ 'n', 'x' }, 'j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true }) +vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true }) +vim.keymap.set({ 'n', 'x' }, 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) +vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) + +-- to window using the hjkl keys +vim.keymap.set('n', '', 'h', { desc = 'Go to Left Window', remap = true }) +vim.keymap.set('n', '', 'j', { desc = 'Go to Lower Window', remap = true }) +vim.keymap.set('n', '', 'k', { desc = 'Go to Upper Window', remap = true }) +vim.keymap.set('n', '', 'l', { desc = 'Go to Right Window', remap = true }) + +vim.keymap.set('n', '', "execute 'move .+' . v:count1==", { desc = 'Move Down' }) +vim.keymap.set('n', '', "execute 'move .-' . (v:count1 + 1)==", { desc = 'Move Up' }) +vim.keymap.set('i', '', 'm .+1==gi', { desc = 'Move Down' }) +vim.keymap.set('i', '', 'm .-2==gi', { desc = 'Move Up' }) +vim.keymap.set('v', '', ":execute \"'<,'>move '>+\" . v:count1gv=gv", { desc = 'Move Down' }) +vim.keymap.set('v', '', ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { desc = 'Move Up' }) + +-- better indenting +vim.keymap.set('v', '<', '', '>gv') + +-- commenting +vim.keymap.set('n', 'gco', 'oVcxnormal gccfxa', { desc = 'Add Comment Below' }) +vim.keymap.set('n', 'gcO', 'OVcxnormal gccfxa', { desc = 'Add Comment Above' }) + +-- windows +vim.keymap.set('n', 'w', '', { desc = 'Windows', remap = true }) +vim.keymap.set('n', '-', 's', { desc = 'Split Window Below', remap = true }) +vim.keymap.set('n', '|', 'v', { desc = 'Split Window Right', remap = true }) +vim.keymap.set('n', 'wd', 'c', { desc = 'Delete Window', remap = true }) + +-- native snippets +if vim.fn.has 'nvim-0.11' == 0 then + vim.keymap.set('s', '', function() + return vim.snippet.active { direction = 1 } and 'lua vim.snippet.jump(1)' or '' + end, { expr = true, desc = 'Jump Next' }) + vim.keymap.set({ 'i', 's' }, '', function() + return vim.snippet.active { direction = -1 } and 'lua vim.snippet.jump(-1)' or '' + end, { expr = true, desc = 'Jump Previous' }) +end diff --git a/lua/custom/keybinds/binds.lua b/lua/custom/keybinds/binds.lua new file mode 100644 index 00000000000..e0a2ec969e8 --- /dev/null +++ b/lua/custom/keybinds/binds.lua @@ -0,0 +1,34 @@ +return { + vim.g.vimtex_view_method == '', + vim.g.vimtex_compiler_method == 'latexmk', + vim.opt.guicursor == 'a:block', + + vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move down' }), + vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move up' }), + + vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }), + vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }), + vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { desc = 'Paste from system clipboard' }), + vim.keymap.set({ 'v', 'n' }, 't', 'TSBufToggle highlight', { desc = 'Toggle Tree-sitter highlighting' }), + vim.keymap.set('n', 'z', ":!zathura =expand('%:r').pdf &", { desc = 'Open PDF' }), + + vim.keymap.set({ 'n' }, 'p', function() + local file_name = vim.fn.expand '%:t' + if file_name ~= '' then + -- Open Explorer in the current directory and select the file + vim.fn.system { 'explorer.exe', '/select,', file_name } + else + print 'No file name found. Save the buffer first.' + end + end, { desc = 'Open file location in Explorer' }), + + vim.keymap.set({ 'n' }, 'o', function() + local file_name = vim.fn.expand '%:t' + if file_name ~= '' then + -- Open Explorer in the current directory and select the file + vim.fn.system { 'explorer.exe', file_name } + else + print 'No file found. Make sure the buffer is saved.' + end + end, { desc = 'Open file ' }), +} diff --git a/lua/custom/plugins/snacks.lua b/lua/custom/plugins/snacks.lua index e84da36d5f9..640c429cf2e 100644 --- a/lua/custom/plugins/snacks.lua +++ b/lua/custom/plugins/snacks.lua @@ -5,7 +5,7 @@ return { ---@type snacks.Config opts = { bigfile = { enabled = true }, - dashboard = { enabled = true }, + dashboard = { enabled = false }, notifier = { enabled = true, timeout = 3000, From 0132c05f5b8e05d8ee7c557f2382540ea99968ec Mon Sep 17 00:00:00 2001 From: BearDad Date: Wed, 20 Nov 2024 18:47:11 +0100 Subject: [PATCH 3/8] setting up setting up finished lulaline i belive we done? i belive we done? config TWEAK: ADDED KEYBINDS tweak FIXUP --- init.lua | 318 +++++++++++++++++++++++------- lua/custom/keybinds/binds.lua | 34 ---- lua/custom/plugins/alpha.lua | 133 +++++++++++++ lua/custom/plugins/dashboard.lua | 18 -- lua/custom/plugins/inc-rename.lua | 5 +- lua/custom/plugins/init.lua | 72 ++++++- lua/custom/plugins/lualine.lua | 4 + lua/custom/plugins/noice.lua | 258 +++++++++++++++++++++++- lua/custom/plugins/snacks.lua | 4 +- lua/custom/plugins/supermaven.lua | 22 ++- 10 files changed, 741 insertions(+), 127 deletions(-) delete mode 100644 lua/custom/keybinds/binds.lua create mode 100644 lua/custom/plugins/alpha.lua delete mode 100644 lua/custom/plugins/dashboard.lua create mode 100644 lua/custom/plugins/lualine.lua diff --git a/init.lua b/init.lua index 6e3b8f72441..593ec2ec08b 100644 --- a/init.lua +++ b/init.lua @@ -22,6 +22,7 @@ What is Kickstart? + Kickstart.nvim is *not* a distribution. Kickstart.nvim is a starting point for your own configuration. @@ -91,7 +92,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = true +vim.g.have_nerd_font = false -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,13 +103,14 @@ vim.g.have_nerd_font = true 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 = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' -- Don't show the mode, since it's already in the status line vim.opt.showmode = false + -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. @@ -128,7 +130,7 @@ vim.opt.ignorecase = true vim.opt.smartcase = true -- Keep signcolumn on by default -vim.opt.signcolumn = 'auto' +vim.opt.signcolumn = 'yes' -- Decrease update time vim.opt.updatetime = 250 @@ -154,7 +156,7 @@ vim.opt.inccommand = 'split' vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 15 +vim.opt.scrolloff = 10 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -175,10 +177,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- TIP: Disable arrow keys in normal mode -vim.keymap.set('n', '', 'echo "Use h to move!!"') -vim.keymap.set('n', '', 'echo "Use l to move!!"') -vim.keymap.set('n', '', 'echo "Use k to move!!"') -vim.keymap.set('n', '', 'echo "Use j to move!!"') +-- vim.keymap.set('n', '', 'echo "Use h to move!!"') +-- vim.keymap.set('n', '', 'echo "Use l to move!!"') +-- vim.keymap.set('n', '', 'echo "Use k to move!!"') +-- vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows @@ -254,6 +256,7 @@ require('lazy').setup({ }, }, }, + -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- -- This is often very useful to both group configuration, as well as handle @@ -268,6 +271,7 @@ require('lazy').setup({ -- Then, because we use the `config` key, the configuration only runs -- after the plugin has been loaded: -- config = function() ... end + { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' @@ -868,12 +872,14 @@ require('lazy').setup({ -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() -- Simple and easy statusline. + require('mini.surround').setup() + + -- Simple and easy statusline. -- You could remove this setup call if you don't like it, -- and try some other statusline plugin local statusline = require 'mini.statusline' -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = true } + statusline.setup { use_icons = vim.g.have_nerd_font } -- You can configure sections in the statusline by overriding their -- default behavior. For example, here we set the section for @@ -887,54 +893,6 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, - { - 'saghen/blink.cmp', - lazy = false, -- lazy loading handled internally - -- optional: provides snippets for the snippet source - dependencies = 'rafamadriz/friendly-snippets', - - -- use a release tag to download pre-built binaries - version = 'v0.*', - -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust - -- build = 'cargo build --release', - -- If you use nix, you can build from source using latest nightly rust with: - -- build = 'nix run .#build-plugin', - - ---@module 'blink.cmp' - ---@type blink.cmp.Config - opts = { - -- 'default' for mappings similar to built-in completion - -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate) - -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept - -- see the "default configuration" section below for full documentation on how to define - -- your own keymap. when defining your own, no keybinds will be assigned automatically. - keymap = 'enter', - - highlight = { - -- sets the fallback highlight groups to nvim-cmp's highlight groups - -- useful for when your theme doesn't support blink.cmp - -- will be removed in a future release, assuming themes add support - use_nvim_cmp_as_default = true, - }, - -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- adjusts spacing to ensure icons are aligned - nerd_font_variant = 'normal', - - -- experimental auto-brackets support - -- accept = { auto_brackets = { enabled = true } } - - -- experimental signature help support - -- trigger = { signature_help = { enabled = true } } - }, - }, - - -- LSP servers and clients communicate what features they support through "capabilities". - -- By default, Neovim support a subset of the LSP specification. - -- With blink.cmp, Neovim has *more* capabilities which are communicated to the LSP servers. - -- Explanation from TJ: https://youtu.be/m8C0Cq9Uv9o?t=1275 - -- - -- This can vary by config, but in-general for nvim-lspconfig: - { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', @@ -971,10 +929,10 @@ require('lazy').setup({ -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.indent_line', require 'kickstart.plugins.lint', require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + -- require 'kickstart.plugins.neo-tree', require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -982,7 +940,6 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. { import = 'custom.plugins' }, - -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -1012,9 +969,9 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et --- --- NOTE: THIS IS ROSEPINE CONFIG --- + +-- NOTE: addietions + require('rose-pine').setup { variant = 'main', -- auto, main, moon, or dawn dark_variant = 'main', -- main, moon, or dawn @@ -1101,9 +1058,15 @@ vim.cmd 'colorscheme rose-pine' -- -- NOTE: This are my personal keybinds -- +-- +-- vim.g.vimtex_view_method = '' vim.g.vimtex_compiler_method = 'latexmk' vim.opt.guicursor = 'a:block' +vim.keymap.set('n', 'e', 'Telescope emoji', { desc = 'Open NerdIcons' }) +vim.cmd [[ + autocmd CmdwinEnter * q +]] vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }) vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }) @@ -1134,9 +1097,9 @@ end, { desc = 'Open file ' }) -- NOTE: THESE ARE FROM https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua vim.keymap.set({ 'n', 'x' }, 'j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true }) -vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true }) +-- vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true }) vim.keymap.set({ 'n', 'x' }, 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) -vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) +-- vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) -- to window using the hjkl keys vim.keymap.set('n', '', 'h', { desc = 'Go to Left Window', remap = true }) @@ -1174,3 +1137,226 @@ if vim.fn.has 'nvim-0.11' == 0 then return vim.snippet.active { direction = -1 } and 'lua vim.snippet.jump(-1)' or '' end, { expr = true, desc = 'Jump Previous' }) end +-- inc rename + +vim.keymap.set('n', 'cr', function() + return ':IncRename ' .. vim.fn.expand '' +end, { expr = true }) + +-- NOTE: END OF LINE CHARS +vim.opt.fillchars = { eob = ' ' } +-- NOTE: LULALINE CONFIG +-- +-- +local lualine = require 'lualine' + +-- Color table for highlights +-- stylua: ignore +local colors = { + bg = '#191724', + fg = '#26233a', + yellow = '#f6c177', + cyan = '#9ccfd8', + darkblue = '#31748f', + green = '#31748f', + orange = '#ebbcba', + violet = '#c4a7e7', + magenta = '#c4a7e7', + blue = '#31748f', + red = 'eb6f92', +} + +local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand '%:t') ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand '%:p:h' + local gitdir = vim.fn.finddir('.git', filepath .. ';') + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, +} + +-- Config +-- +-- + +local config = { + options = { + -- Disable sections and component separators + component_separators = '', + section_separators = '', + theme = { + -- We are going to use lualine_c an lualine_x as left and + -- right section. Both are highlighted by c theme . So we + -- are just setting default looks o statusline + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, + }, + }, + sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + -- These will be filled later + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, +} + +-- Inserts a component in lualine_c at left section +local function ins_left(component) + table.insert(config.sections.lualine_c, component) +end + +-- Inserts a component in lualine_x at right section +local function ins_right(component) + table.insert(config.sections.lualine_x, component) +end + +ins_left { + function() + return '▊' + end, + color = { fg = colors.blue }, -- Sets highlighting of component + padding = { left = 0, right = 1 }, -- We don't need space before this +} + +ins_left { + -- mode component + function() + return '' + end, + color = function() + -- auto change color according to neovims mode + local mode_color = { + n = colors.red, + i = colors.green, + v = colors.blue, + [''] = colors.blue, + V = colors.blue, + c = colors.magenta, + no = colors.red, + s = colors.orange, + S = colors.orange, + [''] = colors.orange, + ic = colors.yellow, + R = colors.violet, + Rv = colors.violet, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.red, + t = colors.red, + } + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { right = 1 }, +} + +ins_left { + -- filesize component + 'filesize', + cond = conditions.buffer_not_empty, + color = { fg = colors.yellow }, +} + +ins_left { + 'filename', + cond = conditions.buffer_not_empty, + color = { fg = colors.magenta, gui = 'bold' }, +} + +ins_left { 'location', color = { fg = colors.yellow } } + +-- Insert mid section. You can make any number of sections in neovim :) +-- for lualine it's any number greater then 2 +ins_left { + function() + return '%=' + end, +} + +ins_left { + icon = ' LSP:', + color = { fg = '#ffffff', gui = 'bold' }, + 'filetype', + -- -- Lsp server name . + -- function() + -- local msg = 'No Active Lsp' + -- local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 }) + -- local clients = vim.lsp.get_clients() + -- if next(clients) == nil then + -- return msg + -- end + -- for _, client in ipairs(clients) do + -- local filetypes = client.config.filetypes + -- if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + -- return client.name + -- end + -- end + -- return msg + -- end, +} + +-- Add components to right sections +-- ins_right { +-- 'o:encoding', -- option component same as &encoding in viml +-- fmt = string.upper, -- I'm not sure why it's upper case either ;) +-- cond = conditions.hide_in_width, +-- color = { fg = colors.green, gui = 'bold' }, +-- } + +-- ins_right { +-- 'fileformat', +-- fmt = string.upper, +-- icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh +-- color = { fg = colors.green, gui = 'bold' }, +-- } + +ins_right { + 'branch', + icon = '', + color = { fg = colors.violet, gui = 'bold' }, +} + +ins_right { + 'diff', + -- Is it me or the symbol for modified us really weird + symbols = { added = ' ', modified = '󰬊 ', removed = ' ' }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.orange }, + removed = { fg = colors.red }, + }, + cond = conditions.hide_in_width, +} + +ins_right { + function() + return '▊' + end, + color = { fg = colors.blue }, + padding = { left = 1 }, +} + +-- Now don't forget to initialize lualine +lualine.setup(config) + +vim.api.nvim_set_hl(0, 'CursorLine', { bg = '#191724' }) -- Use a darker or blended color diff --git a/lua/custom/keybinds/binds.lua b/lua/custom/keybinds/binds.lua deleted file mode 100644 index e0a2ec969e8..00000000000 --- a/lua/custom/keybinds/binds.lua +++ /dev/null @@ -1,34 +0,0 @@ -return { - vim.g.vimtex_view_method == '', - vim.g.vimtex_compiler_method == 'latexmk', - vim.opt.guicursor == 'a:block', - - vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move down' }), - vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move up' }), - - vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }), - vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }), - vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { desc = 'Paste from system clipboard' }), - vim.keymap.set({ 'v', 'n' }, 't', 'TSBufToggle highlight', { desc = 'Toggle Tree-sitter highlighting' }), - vim.keymap.set('n', 'z', ":!zathura =expand('%:r').pdf &", { desc = 'Open PDF' }), - - vim.keymap.set({ 'n' }, 'p', function() - local file_name = vim.fn.expand '%:t' - if file_name ~= '' then - -- Open Explorer in the current directory and select the file - vim.fn.system { 'explorer.exe', '/select,', file_name } - else - print 'No file name found. Save the buffer first.' - end - end, { desc = 'Open file location in Explorer' }), - - vim.keymap.set({ 'n' }, 'o', function() - local file_name = vim.fn.expand '%:t' - if file_name ~= '' then - -- Open Explorer in the current directory and select the file - vim.fn.system { 'explorer.exe', file_name } - else - print 'No file found. Make sure the buffer is saved.' - end - end, { desc = 'Open file ' }), -} diff --git a/lua/custom/plugins/alpha.lua b/lua/custom/plugins/alpha.lua new file mode 100644 index 00000000000..98861209268 --- /dev/null +++ b/lua/custom/plugins/alpha.lua @@ -0,0 +1,133 @@ +return { + + 'goolord/alpha-nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = function() + local alpha = require 'alpha' + local dashboard = require 'alpha.themes.dashboard' + + _Gopts = { + position = 'center', + hl = 'Type', + wrap = 'overflow', + } + + -- DASHBOARD HEADER + + local function getGreeting(name) + local tableTime = os.date '*t' + local datetime = os.date ' %Y-%m-%d-%A  %H:%M:%S ' + local hour = tableTime.hour + local greetingsTable = { + [1] = ' Sleep well', + [2] = ' Good morning', + [3] = ' Good afternoon', + [4] = ' Good evening', + [5] = '󰖔 Good night', + } + local greetingIndex = 0 + if hour == 23 or hour < 7 then + greetingIndex = 1 + elseif hour < 12 then + greetingIndex = 2 + elseif hour >= 12 and hour < 18 then + greetingIndex = 3 + elseif hour >= 18 and hour < 21 then + greetingIndex = 4 + elseif hour >= 21 then + greetingIndex = 5 + end + return datetime .. ' ' .. greetingsTable[greetingIndex] .. ', ' .. name + end + + local logo = [[ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⢔⢅⠣⡣⢑⠅⡇⣆⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⡐⢌⢆⠣⡱⡨⢂⠕⠬⡨⢪⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢊⠐⠌⠔⣁⢦⣣⢵⢬⡢⣃⠅⡉⠺⡮⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠠⢕⢣⢳⡸⣌⠮⢓⡹⣺⢔⣔⣐⢑⢌⠪⡮⠁⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⣀⡦⢗⡞⣟⢮⢥⢀⠣⡗⠉⢳⢹⢪⡫⢞⡮⣖⡥⡣⠺⠀⠀⠀⠀⠀⢀⠠⠈⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⢕⡺⡶⡴⣁⡹⡱⢷⡑⡕⢅⠘⠮⣍⢧⢷⡸⡢⡑⢕⠫⡯⡳⣄⠀⠀⡐⠈⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⢀⢪⡨⢓⡐⣈⠫⠓⡆⠍⠅⠣⡘⡈⢧⢸⢵⢱⡱⢩⢝⡔⡢⢑⢽⢝⡮⣳⡨⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⡧⡤⡎⡚⡉⡅⡋⣊⢝⢼⠇⣌⠌⡆⠙⡺⡬⡇⡇⠅⡢⠑⡑⣵⡳⣆⡂⡝⢪⢣⡻⣪⢆⡀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡏⡜⢜⠍⠲⠢⡨⡫⡵⠗⢧⣢⡁⠜⠀⡌⢝⢌⡇⠅⠌⠢⡉⡮⡎⠌⢌⠚⣧⡳⣝⢮⡫⣞⡀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡣⠞⡣⡢⡑⠡⠑⡦⡊⢎⠉⢌⢚⠄⠪⡘⢜⢼⠂⡡⠠⡈⢄⠪⠸⢭⢌⠝⡘⠕⡎⠕⡝⡮⡪⢄⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⢐⢊⢚⠧⢚⡵⣌⣑⠅⢨⢑⢐⠀⠡⠡⣀⠁⢄⢇⡧⠠⠐⠅⡂⠌⠂⠀⢓⢕⢮⢰⢅⠹⡨⡊⢎⡎⡎⡆⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠘⣀⣲⢽⣸⡔⠀⣀⠡⠺⠐⠁⡱⡝⣬⢖⡝⠡⢊⢔⢢⠑⡐⠅⡈⠀⠀⢌⢎⠕⡕⡕⣇⠕⡬⡂⠱⡕⡵⡀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠥⠩⡓⡕⡍⣹⠁⠄⡬⢐⢀⢴⢯⣳⢕⠥⡑⣙⢜⢔⠅⠂⠨⠀⡠⠀⠜⠬⡨⣘⠸⣜⢬⠂⡑⢡⢪⢪⢣⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⡣⣊⡂⡂⠅⠈⢒⢚⡱⡮⡫⡕⢏⠮⢫⢚⠳⠌⡮⣀⢀⠀⠄⢄⠢⠀⠂⡈⡲⡕⡸⡵⡱⡀⠄⠂⢁⠳⡀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠊⣗⢾⠴⡐⡐⡯⠏⣪⠦⠬⢥⠏⠦⡡⡝⡣⡨⡌⡄⠌⡈⠄⠕⠌⡐⡀⡴⡕⡼⡱⡓⢔⠐⠈⠀⠨⠈⠂⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢊⢆⢇⢇⡳⢙⢲⠺⠭⠬⡉⣐⢰⡣⣈⢂⠥⡀⢀⠀⢢⢈⠠⠀⢄⡯⢮⢫⡪⡣⣃⠪⠈⠀⠄⢑⠀⠄ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠢⡑⣈⢾⡸⣪⠲⣋⢭⣍⡡⠖⣌⡐⣔⠸⡌⡃⠌⠤⡰⣐⡐⣰⠼⠵⡝⢕⠱⡑⢵⢕⠇⠈⠀⠀⡳⣐⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡂⢐⡡⡔⢖⢕⢬⢤⣫⡈⡧⢆⢕⠪⡆⡪⠈⡔⡉⡪⢨⢪⠪⡢⣣⢣⠫⠡⠱⠡⡑⡌⡇⠏⠀⠠⠈⠀⢀⠠⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠔⡨⢪⠱⠨⠨⢒⢊⠲⡱⣪⠺⣍⢂⠵⡘⣘⡠⡣⡣⡒⡬⠠⢱⠱⣱⢕⠥⡨⡸⠸⢜⢜⠬⠊⠀⢀⠐⡀⠌⠠⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢄⠢⡢⠢⠊⠆⢅⠢⡑⢌⠢⢑⠐⢕⢝⠀⠉⡧⡘⡀⢢⠪⠘⠌⠎⢈⢎⠬⠐⠌⠊⠈⠄⠀⡀⢀⠀⢀⠠⠠⠀⡀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡠⡴⠼⢜⢌⠪⡠⢥⢁⠪⢐⠔⢄⢕⢌⡀⠐⠀⠡⠉⠎⠊⢀⠐⢀⢠⠅⠇⠋⠨⠀⠂⠁⠀⠀⡈⠠⠀⠄⠠⠀⠄⠀⠅⠊⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⢀⢄⣄⠀⠀⠀⠀⢄⢖⠁⡎⠪⡣⢅⢓⢜⡐⢕⢕⠂⠌⡊⠢⢑⠘⠘⢈⠂⠂⠃⠑⠐⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢐⠐⡨⠀⠢⠈⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⢁⠢⢊⡠⢂⠢⡲⠑⡌⠪⠉⠀⠀⠠⠘⠔⢅⠣⠡⠂⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⡀⢀⠀⠀⢀⢓⠃⢂⠡⠴⢑⠗⠠⡅⡮⡨⡂⢝⡥⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠆⠁⠀⠀⠅⡀⠀⠀⠁⠀⠀⠀⠈⠈⠈⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠆⠀⠐⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + ]] + + local userName = 'Lazy' + local greeting = getGreeting(userName) + local marginBottom = 0 + dashboard.section.header.val = vim.split(logo, '\n') + + -- Split logo into lines + local logoLines = {} + for line in logo:gmatch '[^\r\n]+' do + table.insert(logoLines, line) + end + + -- Calculate padding for centering the greeting + local logoWidth = logo:find '\n' - 1 -- Assuming the logo width is the width of the first line + local greetingWidth = #greeting + local padding = math.floor((logoWidth - greetingWidth) / 2) + + -- Generate spaces for padding + local paddedGreeting = string.rep(' ', padding) .. greeting + + -- Add margin lines below the padded greeting + local margin = string.rep('\n', marginBottom) + + -- Concatenate logo, padded greeting, and margin + local adjustedLogo = logo .. '\n' .. paddedGreeting .. margin + + dashboard.section.buttons.val = { + dashboard.button('n', ' New file', ':ene startinsert '), + dashboard.button('f', ' Find file', ':cd $HOME | silent Telescope find_files hidden=true no_ignore=true '), + dashboard.button('t', ' Find text', ':Telescope live_grep '), + dashboard.button('r', '󰄉 Recent files', ':Telescope oldfiles '), + dashboard.button('u', '󱐥 Update plugins', 'Lazy update'), + dashboard.button('c', ' Settings', ':e $HOME/.config/nvim/init.lua'), + dashboard.button('p', ' Projects', ':e $HOME/git '), + dashboard.button('d', '󱗼 Dotfiles', ':e $HOME/.dotfiles '), + dashboard.button('q', '󰿅 Quit', 'qa'), + } + + -- local function footer() + -- return "Footer Text" + -- end + + -- dashboard.section.footer.val = vim.split('\n\n' .. getGreeting 'Lazy', '\n') + + vim.api.nvim_create_autocmd('User', { + pattern = 'LazyVimStarted', + desc = 'Add Alpha dashboard footer', + once = true, + callback = function() + local stats = require('lazy').stats() + local ms = math.floor(stats.startuptime * 100 + 0.5) / 100 + dashboard.section.footer.val = { ' ', ' ', ' ', ' Loaded ' .. stats.count .. ' plugins  in ' .. ms .. ' ms ' } + dashboard.section.header.opts.hl = 'DashboardFooter' + pcall(vim.cmd.AlphaRedraw) + end, + }) + + dashboard.opts.opts.noautocmd = true + alpha.setup(dashboard.opts) + end, +} diff --git a/lua/custom/plugins/dashboard.lua b/lua/custom/plugins/dashboard.lua deleted file mode 100644 index 3061293bde5..00000000000 --- a/lua/custom/plugins/dashboard.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - 'nvimdev/dashboard-nvim', - event = 'VimEnter', - theme = 'hyper', - config = function() - require('dashboard').setup { - -- config - -- - } - end, - hide = { - statusline, -- hide statusline default is true - tabline, -- hide the tabline - winbar, -- hide winbar - }, - - dependencies = { { 'nvim-tree/nvim-web-devicons' } }, -} diff --git a/lua/custom/plugins/inc-rename.lua b/lua/custom/plugins/inc-rename.lua index 77bf4f9cab9..cc0089f94ba 100644 --- a/lua/custom/plugins/inc-rename.lua +++ b/lua/custom/plugins/inc-rename.lua @@ -1,5 +1,6 @@ return { 'smjonas/inc-rename.nvim', - cmd = 'IncRename', - opts = {}, + config = function() + require('inc_rename').setup() + end, } diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..2f7b6274edd 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,74 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + + { + 'folke/ts-comments.nvim', + opts = { + { + lang = { + astro = '', + axaml = '', + blueprint = '// %s', + c = '// %s', + c_sharp = '// %s', + clojure = { ';; %s', '; %s' }, + cpp = '// %s', + cs_project = '', + cue = '// %s', + fsharp = '// %s', + fsharp_project = '', + gleam = '// %s', + glimmer = '{{! %s }}', + graphql = '# %s', + handlebars = '{{! %s }}', + hcl = '# %s', + html = '', + hyprlang = '# %s', + ini = '; %s', + ipynb = '# %s', + javascript = { + '// %s', -- default commentstring when no treesitter node matches + '/* %s */', + call_expression = '// %s', -- specific commentstring for call_expression + jsx_attribute = '// %s', + jsx_element = '{/* %s */}', + jsx_fragment = '{/* %s */}', + spread_element = '// %s', + statement_block = '// %s', + }, + kdl = '// %s', + php = '// %s', + rego = '# %s', + rescript = '// %s', + rust = { '// %s', '/* %s */' }, + sql = '-- %s', + styled = '/* %s */', + svelte = '', + templ = { + '// %s', + component_block = '', + }, + terraform = '# %s', + tsx = { + '// %s', -- default commentstring when no treesitter node matches + '/* %s */', + call_expression = '// %s', -- specific commentstring for call_expression + jsx_attribute = '// %s', + jsx_element = '{/* %s */}', + jsx_fragment = '{/* %s */}', + spread_element = '// %s', + statement_block = '// %s', + }, + twig = '{# %s #}', + typescript = { '// %s', '/* %s */' }, -- langs can have multiple commentstrings + vue = '', + xaml = '', + }, + }, + }, + event = 'VeryLazy', + enabled = vim.fn.has 'nvim-0.10.0' == 1, + }, +} diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000000..13fff7137be --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,4 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, +} diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua index c4245ef75e9..c141131ac37 100644 --- a/lua/custom/plugins/noice.lua +++ b/lua/custom/plugins/noice.lua @@ -1,7 +1,261 @@ +-- lazy.nvim return { 'folke/noice.nvim', - optional = true, + event = 'VeryLazy', opts = { - presets = { inc_rename = true }, + -- add any options here + }, + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + 'MunifTanjim/nui.nvim', + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + 'rcarriga/nvim-notify', + }, + require('noice').setup { + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + cmdline = { + format = { + cmdline = { icon = '>' }, + search_down = { icon = '🔍⌄' }, + search_up = { icon = '🔍⌃' }, + filter = { icon = '$' }, + lua = { icon = '☾' }, + help = { icon = '?' }, + }, + }, + format = { + level = { + icons = { + error = '✖', + warn = '▼', + info = '●', + }, + }, + }, + popupmenu = { + kind_icons = false, + }, + inc_rename = { + cmdline = { + format = { + IncRename = { icon = '⟳' }, + }, + }, + }, + { + cmdline = { + enabled = true, -- enables the Noice cmdline UI + view = 'cmdline_popup', -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom + opts = {}, -- global options for the cmdline. See section on views + ---@type table + format = { + -- conceal: (default=true) This will hide the text in the cmdline that matches the pattern. + -- view: (default is cmdline view) + -- opts: any options passed to the view + -- icon_hl_group: optional hl_group for the icon + -- title: set to anything or empty string to hide + cmdline = { pattern = '^:', icon = '', lang = 'vim' }, + search_down = { kind = 'search', pattern = '^/', icon = ' ', lang = 'regex' }, + search_up = { kind = 'search', pattern = '^%?', icon = ' ', lang = 'regex' }, + filter = { pattern = '^:%s*!', icon = '$', lang = 'bash' }, + lua = { pattern = { '^:%s*lua%s+', '^:%s*lua%s*=%s*', '^:%s*=%s*' }, icon = '', lang = 'lua' }, + help = { pattern = '^:%s*he?l?p?%s+', icon = '' }, + input = { view = 'cmdline_input', icon = '󰥻 ' }, -- Used by input() + -- lua = false, -- to disable a format, set to `false` + }, + }, + messages = { + -- NOTE: If you enable messages, then the cmdline is enabled automatically. + -- This is a current Neovim limitation. + enabled = true, -- enables the Noice messages UI + view = 'notify', -- default view for messages + view_error = 'notify', -- view for errors + view_warn = 'notify', -- view for warnings + view_history = 'messages', -- view for :messages + view_search = 'virtualtext', -- view for search count messages. Set to `false` to disable + }, + popupmenu = { + enabled = true, -- enables the Noice popupmenu UI + ---@type 'nui'|'cmp' + backend = 'nui', -- backend to use to show regular cmdline completions + ---@type NoicePopupmenuItemKind|false + -- Icons for completion item kinds (see defaults at noice.config.icons.kinds) + kind_icons = {}, -- set to `false` to disable icons + }, + -- default options for require('noice').redirect + -- see the section on Command Redirection + ---@type NoiceRouteConfig + redirect = { + view = 'popup', + filter = { event = 'msg_show' }, + }, + -- You can add any custom commands below that will be available with `:Noice command` + ---@type table + commands = { + history = { + -- options for the message history that you get with `:Noice` + view = 'split', + opts = { enter = true, format = 'details' }, + filter = { + any = { + { event = 'notify' }, + { error = true }, + { warning = true }, + { event = 'msg_show', kind = { '' } }, + { event = 'lsp', kind = 'message' }, + }, + }, + }, + -- :Noice last + last = { + view = 'popup', + opts = { enter = true, format = 'details' }, + filter = { + any = { + { event = 'notify' }, + { error = true }, + { warning = true }, + { event = 'msg_show', kind = { '' } }, + { event = 'lsp', kind = 'message' }, + }, + }, + filter_opts = { count = 1 }, + }, + -- :Noice errors + errors = { + -- options for the message history that you get with `:Noice` + view = 'popup', + opts = { enter = true, format = 'details' }, + filter = { error = true }, + filter_opts = { reverse = true }, + }, + all = { + -- options for the message history that you get with `:Noice` + view = 'split', + opts = { enter = true, format = 'details' }, + filter = {}, + }, + }, + notify = { + -- Noice can be used as `vim.notify` so you can route any notification like other messages + -- Notification messages have their level and other properties set. + -- event is always "notify" and kind can be any log level as a string + -- The default routes will forward notifications to nvim-notify + -- Benefit of using Noice for this is the routing and consistent history view + enabled = true, + view = 'notify', + }, + lsp = { + progress = { + enabled = true, + -- Lsp Progress is formatted using the builtins for lsp_progress. See config.format.builtin + -- See the section on formatting for more details on how to customize. + --- @type NoiceFormat|string + format = 'lsp_progress', + --- @type NoiceFormat|string + format_done = 'lsp_progress_done', + throttle = 1000 / 30, -- frequency to update lsp progress message + view = 'mini', + }, + override = { + -- override the default lsp markdown formatter with Noice + ['vim.lsp.util.convert_input_to_markdown_lines'] = false, + -- override the lsp markdown formatter with Noice + ['vim.lsp.util.stylize_markdown'] = false, + -- override cmp documentation with Noice (needs the other options to work) + ['cmp.entry.get_documentation'] = false, + }, + hover = { + enabled = true, + silent = false, -- set to true to not show a message if hover is not available + view = nil, -- when nil, use defaults from documentation + ---@type NoiceViewOptions + opts = {}, -- merged with defaults from documentation + }, + signature = { + enabled = true, + auto_open = { + enabled = true, + trigger = true, -- Automatically show signature help when typing a trigger character from the LSP + luasnip = true, -- Will open signature help when jumping to Luasnip insert nodes + throttle = 50, -- Debounce lsp signature help request by 50ms + }, + view = nil, -- when nil, use defaults from documentation + ---@type NoiceViewOptions + opts = {}, -- merged with defaults from documentation + }, + message = { + -- Messages shown by lsp servers + enabled = true, + view = 'notify', + opts = {}, + }, + -- defaults for hover and signature help + documentation = { + view = 'hover', + ---@type NoiceViewOptions + opts = { + lang = 'markdown', + replace = true, + render = 'plain', + format = { '{message}' }, + win_options = { concealcursor = 'n', conceallevel = 3 }, + }, + }, + }, + markdown = { + hover = { + ['|(%S-)|'] = vim.cmd.help, -- vim help links + ['%[.-%]%((%S-)%)'] = require('noice.util').open, -- markdown links + }, + highlights = { + ['|%S-|'] = '@text.reference', + ['@%S+'] = '@parameter', + ['^%s*(Parameters:)'] = '@text.title', + ['^%s*(Return:)'] = '@text.title', + ['^%s*(See also:)'] = '@text.title', + ['{%S-}'] = '@parameter', + }, + }, + health = { + checker = true, -- Disable if you don't want health checks to run + }, + ---@type NoicePresets + presets = { + -- you can enable a preset by setting it to true, or a table that will override the preset config + -- you can also add custom presets that you can enable/disable with enabled=true + bottom_search = false, -- use a classic bottom cmdline for search + command_palette = false, -- position the cmdline and popupmenu together + long_message_to_split = false, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + throttle = 1000 / 30, -- how frequently does Noice need to check for ui updates? This has no effect when in blocking mode. + ---@type NoiceConfigViews + views = {}, ---@see section on views + ---@type NoiceRouteConfig[] + routes = {}, --- @see section on routes + ---@type table + status = {}, --- @see section on statusline components + ---@type NoiceFormatOptions + format = {}, --- @see section on formatting + }, }, } diff --git a/lua/custom/plugins/snacks.lua b/lua/custom/plugins/snacks.lua index 640c429cf2e..7a599fecf83 100644 --- a/lua/custom/plugins/snacks.lua +++ b/lua/custom/plugins/snacks.lua @@ -11,8 +11,8 @@ return { timeout = 3000, }, quickfile = { enabled = true }, - statuscolumn = { enabled = true }, - words = { enabled = true }, + statuscolumn = { enabled = false }, + words = { enabled = false }, styles = { notification = { wo = { wrap = true }, -- Wrap notifications diff --git a/lua/custom/plugins/supermaven.lua b/lua/custom/plugins/supermaven.lua index cf8813470f1..b4518565d24 100644 --- a/lua/custom/plugins/supermaven.lua +++ b/lua/custom/plugins/supermaven.lua @@ -1,8 +1,26 @@ return { { - "supermaven-inc/supermaven-nvim", + 'supermaven-inc/supermaven-nvim', config = function() - require("supermaven-nvim").setup({}) + require('supermaven-nvim').setup { + keymaps = { + accept_suggestion = '', + clear_suggestion = '', + accept_word = '', + }, + ignore_filetypes = { cpp = true }, -- or { "cpp", } + color = { + suggestion_color = '#c4a7e7', + + cterm = 244, + }, + log_level = 'info', -- set to "off" to disable logging completely + disable_inline_completion = false, -- disables inline completion for use with cmp + disable_keymaps = false, -- disables built in keymaps for more manual control + condition = function() + return false + end, -- condition to check for stopping supermaven, `true` means to stop supermaven when the condition is true. + } end, }, } From 58b7a9ee82132de47b8526437f5da1dbe83adc3f Mon Sep 17 00:00:00 2001 From: BearDad Date: Sat, 23 Nov 2024 22:00:36 +0100 Subject: [PATCH 4/8] Tweak: tmux-vim --- init.lua | 8 ++++---- lua/custom/plugins/tmux-vim.lua | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/init.lua b/init.lua index 593ec2ec08b..faae6cfede2 100644 --- a/init.lua +++ b/init.lua @@ -1102,10 +1102,10 @@ vim.keymap.set({ 'n', 'x' }, 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', ex -- vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) -- to window using the hjkl keys -vim.keymap.set('n', '', 'h', { desc = 'Go to Left Window', remap = true }) -vim.keymap.set('n', '', 'j', { desc = 'Go to Lower Window', remap = true }) -vim.keymap.set('n', '', 'k', { desc = 'Go to Upper Window', remap = true }) -vim.keymap.set('n', '', 'l', { desc = 'Go to Right Window', remap = true }) +-- vim.keymap.set('n', '', 'h', { desc = 'Go to Left Window', remap = true }) +-- vim.keymap.set('n', '', 'j', { desc = 'Go to Lower Window', remap = true }) +-- vim.keymap.set('n', '', 'k', { desc = 'Go to Upper Window', remap = true }) +-- vim.keymap.set('n', '', 'l', { desc = 'Go to Right Window', remap = true }) vim.keymap.set('n', '', "execute 'move .+' . v:count1==", { desc = 'Move Down' }) vim.keymap.set('n', '', "execute 'move .-' . (v:count1 + 1)==", { desc = 'Move Up' }) diff --git a/lua/custom/plugins/tmux-vim.lua b/lua/custom/plugins/tmux-vim.lua index 4421fed9a43..9d680e2668b 100755 --- a/lua/custom/plugins/tmux-vim.lua +++ b/lua/custom/plugins/tmux-vim.lua @@ -1,17 +1,18 @@ return { - "christoomey/vim-tmux-navigator", + 'christoomey/vim-tmux-navigator', + lazy = false, cmd = { - "TmuxNavigateLeft", - "TmuxNavigateDown", - "TmuxNavigateUp", - "TmuxNavigateRight", - "TmuxNavigatePrevious", + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', }, keys = { - { "", "TmuxNavigateLeft" }, - { "", "TmuxNavigateDown" }, - { "", "TmuxNavigateUp" }, - { "", "TmuxNavigateRight" }, - { "", "TmuxNavigatePrevious" }, + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + { '', 'TmuxNavigatePrevious' }, }, } From 62862160717cf79570a2c811fe79ad7f3a82528d Mon Sep 17 00:00:00 2001 From: BearDad Date: Mon, 25 Nov 2024 19:32:49 +0100 Subject: [PATCH 5/8] TWEAK --- lua/custom/plugins/alpha.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/custom/plugins/alpha.lua b/lua/custom/plugins/alpha.lua index 98861209268..49dead1db1f 100644 --- a/lua/custom/plugins/alpha.lua +++ b/lua/custom/plugins/alpha.lua @@ -104,6 +104,7 @@ return { dashboard.button('u', '󱐥 Update plugins', 'Lazy update'), dashboard.button('c', ' Settings', ':e $HOME/.config/nvim/init.lua'), dashboard.button('p', ' Projects', ':e $HOME/git '), + dashboard.button('', ' Clase', ':e $HOME/obsidian/Clase/ '), dashboard.button('d', '󱗼 Dotfiles', ':e $HOME/.dotfiles '), dashboard.button('q', '󰿅 Quit', 'qa'), } From fb81087eefce42e846326a4866f2cf1dd4e39969 Mon Sep 17 00:00:00 2001 From: BearDad Date: Fri, 29 Nov 2024 19:28:57 +0100 Subject: [PATCH 6/8] TWEAK --- init.lua | 35 +++++++++++++++++++++++++++++++++++ lua/chadrc.lua | 1 + lua/custom/plugins/alpha.lua | 2 +- lua/custom/plugins/init.lua | 6 ++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 lua/chadrc.lua diff --git a/init.lua b/init.lua index faae6cfede2..edb3d2e2668 100644 --- a/init.lua +++ b/init.lua @@ -1359,4 +1359,39 @@ ins_right { -- Now don't forget to initialize lualine lualine.setup(config) +require('colorizer').setup { + filetypes = { '*' }, + user_default_options = { + names = true, -- "Name" codes like Blue or blue + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + RRGGBBAA = true, -- #RRGGBBAA hex codes + AARRGGBB = true, -- 0xAARRGGBB hex codes + rgb_fn = true, -- CSS rgb() and rgba() functions + hsl_fn = true, -- CSS hsl() and hsla() functions + css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Highlighting mode. 'background'|'foreground'|'virtualtext' + mode = 'background', -- Set the display mode + -- Tailwind colors. boolean|'normal'|'lsp'|'both'. True is same as normal + tailwind = 'both', -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = true, parsers = { 'css' } }, -- Enable sass colors + -- Virtualtext character to use + virtualtext = '■', + -- Display virtualtext inline with color + virtualtext_inline = true, + -- Virtualtext highlight mode: 'background'|'foreground' + virtualtext_mode = 'foreground', + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = true, + }, + -- all the sub-options of filetypes apply to buftypes + buftypes = {}, + -- Boolean | List of usercommands to enable + user_commands = true, -- Enable all or some usercommands +} + vim.api.nvim_set_hl(0, 'CursorLine', { bg = '#191724' }) -- Use a darker or blended color +vim.wo.relativenumber = true diff --git a/lua/chadrc.lua b/lua/chadrc.lua new file mode 100644 index 00000000000..a564707544f --- /dev/null +++ b/lua/chadrc.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/custom/plugins/alpha.lua b/lua/custom/plugins/alpha.lua index 49dead1db1f..b115fb78cfa 100644 --- a/lua/custom/plugins/alpha.lua +++ b/lua/custom/plugins/alpha.lua @@ -83,7 +83,7 @@ return { end -- Calculate padding for centering the greeting - local logoWidth = logo:find '\n' - 1 -- Assuming the logo width is the width of the first line + local logoWidth = logo:find '\n' - 18 -- Assuming the logo width is the width of the first line local greetingWidth = #greeting local padding = math.floor((logoWidth - greetingWidth) / 2) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 2f7b6274edd..12e18418f26 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -72,4 +72,10 @@ return { event = 'VeryLazy', enabled = vim.fn.has 'nvim-0.10.0' == 1, }, + { + 'NvChad/nvim-colorizer.lua', + event = 'BufReadPre', + opts = { -- set to setup table + }, + }, } From 502e196ea4e6bf8421b22ed2b1bedee327a0c218 Mon Sep 17 00:00:00 2001 From: BearDad Date: Fri, 29 Nov 2024 19:53:17 +0100 Subject: [PATCH 7/8] TWEAK --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index edb3d2e2668..0aea26dbdeb 100644 --- a/init.lua +++ b/init.lua @@ -1393,5 +1393,6 @@ require('colorizer').setup { user_commands = true, -- Enable all or some usercommands } +vim.opt.termguicolors = true vim.api.nvim_set_hl(0, 'CursorLine', { bg = '#191724' }) -- Use a darker or blended color vim.wo.relativenumber = true From c66b2029fc824fb0e2950fb973902e29217b66aa Mon Sep 17 00:00:00 2001 From: BearDad Date: Sun, 26 Apr 2026 15:34:35 +0200 Subject: [PATCH 8/8] a --- init.lua | 931 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 536 insertions(+), 395 deletions(-) diff --git a/init.lua b/init.lua index 0aea26dbdeb..07108c3a775 100644 --- a/init.lua +++ b/init.lua @@ -92,7 +92,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -244,6 +244,11 @@ require('lazy').setup({ -- require('gitsigns').setup({ ... }) -- -- See `:help gitsigns` to understand what the configuration keys do + { + 'nvim-tree/nvim-web-devicons', + enabled = true, + lazy = false, + }, { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { @@ -355,7 +360,6 @@ require('lazy').setup({ { 'nvim-telescope/telescope-ui-select.nvim' }, -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -463,7 +467,7 @@ require('lazy').setup({ -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, + { 'j-hui/fidget.nvim', lazy = false, opts = {} }, -- Allows extra capabilities provided by nvim-cmp 'hrsh7th/cmp-nvim-lsp', @@ -554,7 +558,7 @@ require('lazy').setup({ -- -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, @@ -581,7 +585,7 @@ require('lazy').setup({ -- code, if the language server you are using supports them -- -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') @@ -615,6 +619,45 @@ require('lazy').setup({ -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + vim.lsp.config('gdscript', { + cmd = vim.lsp.rpc.connect('127.0.0.1', 6005), + filetypes = { 'gdscript' }, + root_dir = vim.fs.root(0, { 'project.godot', '.git' }), + }) + vim.lsp.enable 'gdscript' + + vim.lsp.config('basedpyright', { + settings = { + basedpyright = { + analysis = { + typeCheckingMode = 'standard', + autoSearchPaths = true, + useLibraryCodeForTypes = true, + autoImportCompletions = true, + diagnosticMode = 'workspace', -- sobreescribe el "openFilesOnly" del default + }, + }, + }, + }) + + vim.lsp.enable 'basedpyright' + + vim.lsp.config('arduino_language_server', { + cmd = { + 'arduino-language-server', + '-clangd', + vim.fn.exepath 'clangd', + '-cli', + vim.fn.exepath 'arduino-cli', + '-cli-config', + vim.fn.expand '~/.arduino15/arduino-cli.yaml', + '-fqbn', + 'arduino:avr:mega', + }, + }) + + vim.lsp.enable 'arduino_language_server' + local servers = { -- clangd = {}, -- gopls = {}, @@ -669,10 +712,13 @@ require('lazy').setup({ -- by the server configuration above. Useful when disabling -- certain features of an LSP (for example, turning off formatting for ts_ls) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) + vim.lsp.config(server_name, server) + vim.lsp.enable(server_name) end, }, } + -- GDScript (Godot 4) — el servidor está integrado en Godot, no en Mason + -- Godot debe estar abierto con el proyecto para que el LSP funcione end, }, @@ -696,7 +742,8 @@ require('lazy').setup({ -- Disable "format_on_save lsp_fallback" for languages that don't -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } + -- local disable_filetypes = { c = true, cpp = true } + local disable_filetypes = {} local lsp_format_opt if disable_filetypes[vim.bo[bufnr].filetype] then lsp_format_opt = 'never' @@ -710,6 +757,19 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + go = { 'goimports' }, + python = { 'ruff_format' }, + javascript = { 'prettierd', 'prettier', stop_after_first = true }, + typescript = { 'prettierd', 'prettier', stop_after_first = true }, + javascriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + typescriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + css = { 'prettierd', 'prettier', stop_after_first = true }, + html = { 'prettierd', 'prettier', stop_after_first = true }, + json = { 'prettierd', 'prettier', stop_after_first = true }, + yaml = { 'prettierd', 'prettier', stop_after_first = true }, + markdown = { 'prettierd', 'prettier', stop_after_first = true }, + c = { 'clang_format' }, + cpp = { 'clang_format' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -739,12 +799,27 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + require('luasnip.loaders.from_snipmate').lazy_load() + require('luasnip.loaders.from_lua').lazy_load() + require('luasnip').filetype_extend('typescript', { 'tsdoc' }) + require('luasnip').filetype_extend('javascript', { 'jsdoc' }) + require('luasnip').filetype_extend('lua', { 'luadoc' }) + require('luasnip').filetype_extend('python', { 'pydoc' }) + require('luasnip').filetype_extend('rust', { 'rustdoc' }) + require('luasnip').filetype_extend('cs', { 'csharpdoc' }) + require('luasnip').filetype_extend('java', { 'javadoc' }) + require('luasnip').filetype_extend('c', { 'cdoc' }) + require('luasnip').filetype_extend('cpp', { 'cppdoc' }) + require('luasnip').filetype_extend('php', { 'phpdoc' }) + require('luasnip').filetype_extend('kotlin', { 'kdoc' }) + require('luasnip').filetype_extend('ruby', { 'rdoc' }) + require('luasnip').filetype_extend('sh', { 'shelldoc' }) + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -790,10 +865,10 @@ require('lazy').setup({ -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), - + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + -- -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display -- completions whenever it has completion options available. @@ -856,68 +931,70 @@ require('lazy').setup({ -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + lazy = false, + build = ':TSUpdate', + branch = 'main', + -- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro` config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } + -- ensure basic parser are installed + local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } + require('nvim-treesitter').install(parsers) + + ---@param buf integer + ---@param language string + local function treesitter_try_attach(buf, language) + -- check if parser exists and load it + if not vim.treesitter.language.add(language) then + return + end + -- enables syntax highlighting and other treesitter features + vim.treesitter.start(buf, language) - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' + -- enables treesitter based folds + -- for more info on folds see `:help folds` + vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + vim.wo.foldmethod = 'expr' + + -- check if treesitter indentation is available for this language, and if so enable it + -- in case there is no indent query, the indentexpr will fallback to the vim's built in one + local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil + + -- enables treesitter based indentation + if has_indent_query then + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end end - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim + local available_parsers = require('nvim-treesitter').get_available() + vim.api.nvim_create_autocmd('FileType', { + callback = function(args) + local buf, filetype = args.buf, args.match + + local language = vim.treesitter.language.get_lang(filetype) + if not language then + return + end + + local installed_parsers = require('nvim-treesitter').get_installed 'parsers' + + if vim.tbl_contains(installed_parsers, language) then + -- enable the parser if it is installed + treesitter_try_attach(buf, language) + elseif vim.tbl_contains(available_parsers, language) then + -- if a parser is available in `nvim-treesitter` auto install it, and enable it after the installation is done + require('nvim-treesitter').install(language):await(function() + treesitter_try_attach(buf, language) + end) + else + -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` + treesitter_try_attach(buf, language) + end + end, + }) end, }, - { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- 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' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and @@ -971,128 +1048,86 @@ require('lazy').setup({ -- vim: ts=2 sts=2 sw=2 et -- NOTE: addietions - -require('rose-pine').setup { - variant = 'main', -- auto, main, moon, or dawn - dark_variant = 'main', -- main, moon, or dawn - dim_inactive_windows = false, - extend_background_behind_borders = true, - - enable = { - terminal = true, - legacy_highlights = true, -- Improve compatibility for previous versions of Neovim - migrations = true, -- Handle deprecated options automatically - }, - - styles = { - bold = true, - italic = true, - transparency = true, - }, - - groups = { - border = 'muted', - link = 'iris', - panel = 'surface', - - error = 'love', - hint = 'iris', - info = 'foam', - note = 'pine', - todo = 'rose', - warn = 'gold', - - git_add = 'foam', - git_change = 'rose', - git_delete = 'love', - git_dirty = 'rose', - git_ignore = 'muted', - git_merge = 'iris', - git_rename = 'pine', - git_stage = 'iris', - git_text = 'rose', - git_untracked = 'subtle', - - h1 = 'iris', - h2 = 'foam', - h3 = 'rose', - h4 = 'gold', - h5 = 'pine', - h6 = 'foam', - }, - - palette = { - -- Override the builtin palette per variant - moon = { - base = '#18191a', - overlay = '#363738', - }, - }, - - highlight_groups = { - Comment = { fg = 'foam' }, - VertSplit = { fg = 'muted', bg = 'muted' }, +-- +-- +---- Default options: +require('kanagawa').setup { + compile = false, -- enable compiling the colorscheme + undercurl = true, -- enable undercurls + commentStyle = { italic = true }, + functionStyle = {}, + keywordStyle = { italic = true }, + statementStyle = { bold = true }, + typeStyle = {}, + transparent = true, -- do not set background color + dimInactive = true, -- dim inactive window `:h hl-NormalNC` + terminalColors = true, -- define vim.g.terminal_color_{0,17} + colors = { -- add/modify theme and palette colors + palette = {}, + theme = { wave = {}, lotus = {}, dragon = {}, all = { + ui = { + bg_gutter = 'none', + }, + } }, }, - - before_highlight = function(group, highlight, palette) - -- Disable all undercurls - -- if highlight.undercurl then - -- highlight.undercurl = false - -- end - -- - -- Change palette colour - -- if highlight.fg == palette.pine then - -- highlight.fg = palette.foam - -- end + overrides = function(colors) + local theme = colors.theme + return { + NormalFloat = { bg = 'none' }, + FloatBorder = { bg = 'none' }, + FloatTitle = { bg = 'none' }, + + -- Save an hlgroup with dark background and dimmed foreground + -- so that you can use it where your still want darker windows. + -- E.g.: autocmd TermOpen * setlocal winhighlight=Normal:NormalDark + NormalDark = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m3 }, + + -- Popular plugins that open floats will link to NormalFloat by default; + -- set their background accordingly if you wish to keep them dark and borderless + LazyNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim }, + MasonNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim }, + + TelescopeTitle = { fg = theme.ui.special, bold = true }, + TelescopePromptNormal = { bg = theme.ui.bg_p1 }, + TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = theme.ui.bg_p1 }, + TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m1 }, + TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = theme.ui.bg_m1 }, + TelescopePreviewNormal = { bg = theme.ui.bg_dim }, + TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim }, + } end, + theme = 'dragon', -- Load "wave" theme + background = { -- map the value of 'background' option to a theme + dark = 'dragon', -- try "dragon" ! + light = 'lotus', + }, } -vim.cmd 'colorscheme rose-pine' --- vim.cmd("colorscheme rose-pine-main") --- vim.cmd("colorscheme rose-pine-moon") --- vim.cmd("colorscheme rose-pine-dawn") --- --- --- +-- setup must be called before loading +vim.cmd 'colorscheme kanagawa' -- -- -- NOTE: This are my personal keybinds -- -- --- -vim.g.vimtex_view_method = '' +vim.g.vimtex_view_method = 'zathura' vim.g.vimtex_compiler_method = 'latexmk' -vim.opt.guicursor = 'a:block' -vim.keymap.set('n', 'e', 'Telescope emoji', { desc = 'Open NerdIcons' }) + +vim.keymap.set('n', 'ee', 'Telescope emoji', { desc = 'Open NerdIcons' }) vim.cmd [[ autocmd CmdwinEnter * q ]] - +vim.opt.guicursor = 'n-v-c:block,i-ci-ve:hor1-blinkon0' vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }) vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }) vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { desc = 'Paste from system clipboard' }) -vim.keymap.set({ 'v', 'n' }, 't', 'TSBufToggle highlight', { desc = 'Toggle Tree-sitter highlighting' }) -vim.keymap.set('n', 'z', ":!zathura =expand('%:r').pdf &", { desc = 'Open PDF' }) - -vim.keymap.set({ 'n' }, 'p', function() - local file_name = vim.fn.expand '%:t' - if file_name ~= '' then - -- Open Explorer in the current directory and select the file - vim.fn.system { 'explorer.exe', '/select,', file_name } - else - print 'No file name found. Save the buffer first.' - end -end, { desc = 'Open file location in Explorer' }) - -vim.keymap.set({ 'n' }, 'o', function() - local file_name = vim.fn.expand '%:t' - if file_name ~= '' then - -- Open Explorer in the current directory and select the file - vim.fn.system { 'explorer.exe', file_name } - else - print 'No file found. Make sure the buffer is saved.' - end -end, { desc = 'Open file ' }) +vim.keymap.set({ 'v', 'n' }, 'tt', 'TSBufToggle highlight', { desc = 'Toggle Tree-sitter highlighting' }) +vim.keymap.set({ 'n', 'v', 'x' }, ';', ':') +vim.keymap.set({ 'n', 'v', 'x' }, ':', ';') + +vim.keymap.set({ 'x', 'n' }, '', [[:'<,'>s/]], { desc = 'Enter substitute mode' }) + +-- -- NOTE: THESE ARE FROM https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua @@ -1108,10 +1143,10 @@ vim.keymap.set({ 'n', 'x' }, 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', ex -- vim.keymap.set('n', '', 'l', { desc = 'Go to Right Window', remap = true }) vim.keymap.set('n', '', "execute 'move .+' . v:count1==", { desc = 'Move Down' }) -vim.keymap.set('n', '', "execute 'move .-' . (v:count1 + 1)==", { desc = 'Move Up' }) vim.keymap.set('i', '', 'm .+1==gi', { desc = 'Move Down' }) -vim.keymap.set('i', '', 'm .-2==gi', { desc = 'Move Up' }) vim.keymap.set('v', '', ":execute \"'<,'>move '>+\" . v:count1gv=gv", { desc = 'Move Down' }) +vim.keymap.set('n', '', "execute 'move .-' . (v:count1 + 1)==", { desc = 'Move Up' }) +vim.keymap.set('i', '', 'm .-2==gi', { desc = 'Move Up' }) vim.keymap.set('v', '', ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { desc = 'Move Up' }) -- better indenting @@ -1141,223 +1176,10 @@ end vim.keymap.set('n', 'cr', function() return ':IncRename ' .. vim.fn.expand '' -end, { expr = true }) +end, { expr = true, desc = 'Rename' }) -- NOTE: END OF LINE CHARS vim.opt.fillchars = { eob = ' ' } --- NOTE: LULALINE CONFIG --- --- -local lualine = require 'lualine' - --- Color table for highlights --- stylua: ignore -local colors = { - bg = '#191724', - fg = '#26233a', - yellow = '#f6c177', - cyan = '#9ccfd8', - darkblue = '#31748f', - green = '#31748f', - orange = '#ebbcba', - violet = '#c4a7e7', - magenta = '#c4a7e7', - blue = '#31748f', - red = 'eb6f92', -} - -local conditions = { - buffer_not_empty = function() - return vim.fn.empty(vim.fn.expand '%:t') ~= 1 - end, - hide_in_width = function() - return vim.fn.winwidth(0) > 80 - end, - check_git_workspace = function() - local filepath = vim.fn.expand '%:p:h' - local gitdir = vim.fn.finddir('.git', filepath .. ';') - return gitdir and #gitdir > 0 and #gitdir < #filepath - end, -} - --- Config --- --- - -local config = { - options = { - -- Disable sections and component separators - component_separators = '', - section_separators = '', - theme = { - -- We are going to use lualine_c an lualine_x as left and - -- right section. Both are highlighted by c theme . So we - -- are just setting default looks o statusline - normal = { c = { fg = colors.fg, bg = colors.bg } }, - inactive = { c = { fg = colors.fg, bg = colors.bg } }, - }, - }, - sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - -- These will be filled later - lualine_c = {}, - lualine_x = {}, - }, - inactive_sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - lualine_c = {}, - lualine_x = {}, - }, -} - --- Inserts a component in lualine_c at left section -local function ins_left(component) - table.insert(config.sections.lualine_c, component) -end - --- Inserts a component in lualine_x at right section -local function ins_right(component) - table.insert(config.sections.lualine_x, component) -end - -ins_left { - function() - return '▊' - end, - color = { fg = colors.blue }, -- Sets highlighting of component - padding = { left = 0, right = 1 }, -- We don't need space before this -} - -ins_left { - -- mode component - function() - return '' - end, - color = function() - -- auto change color according to neovims mode - local mode_color = { - n = colors.red, - i = colors.green, - v = colors.blue, - [''] = colors.blue, - V = colors.blue, - c = colors.magenta, - no = colors.red, - s = colors.orange, - S = colors.orange, - [''] = colors.orange, - ic = colors.yellow, - R = colors.violet, - Rv = colors.violet, - cv = colors.red, - ce = colors.red, - r = colors.cyan, - rm = colors.cyan, - ['r?'] = colors.cyan, - ['!'] = colors.red, - t = colors.red, - } - return { fg = mode_color[vim.fn.mode()] } - end, - padding = { right = 1 }, -} - -ins_left { - -- filesize component - 'filesize', - cond = conditions.buffer_not_empty, - color = { fg = colors.yellow }, -} - -ins_left { - 'filename', - cond = conditions.buffer_not_empty, - color = { fg = colors.magenta, gui = 'bold' }, -} - -ins_left { 'location', color = { fg = colors.yellow } } - --- Insert mid section. You can make any number of sections in neovim :) --- for lualine it's any number greater then 2 -ins_left { - function() - return '%=' - end, -} - -ins_left { - icon = ' LSP:', - color = { fg = '#ffffff', gui = 'bold' }, - 'filetype', - -- -- Lsp server name . - -- function() - -- local msg = 'No Active Lsp' - -- local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 }) - -- local clients = vim.lsp.get_clients() - -- if next(clients) == nil then - -- return msg - -- end - -- for _, client in ipairs(clients) do - -- local filetypes = client.config.filetypes - -- if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - -- return client.name - -- end - -- end - -- return msg - -- end, -} - --- Add components to right sections --- ins_right { --- 'o:encoding', -- option component same as &encoding in viml --- fmt = string.upper, -- I'm not sure why it's upper case either ;) --- cond = conditions.hide_in_width, --- color = { fg = colors.green, gui = 'bold' }, --- } - --- ins_right { --- 'fileformat', --- fmt = string.upper, --- icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh --- color = { fg = colors.green, gui = 'bold' }, --- } - -ins_right { - 'branch', - icon = '', - color = { fg = colors.violet, gui = 'bold' }, -} - -ins_right { - 'diff', - -- Is it me or the symbol for modified us really weird - symbols = { added = ' ', modified = '󰬊 ', removed = ' ' }, - diff_color = { - added = { fg = colors.green }, - modified = { fg = colors.orange }, - removed = { fg = colors.red }, - }, - cond = conditions.hide_in_width, -} - -ins_right { - function() - return '▊' - end, - color = { fg = colors.blue }, - padding = { left = 1 }, -} - --- Now don't forget to initialize lualine -lualine.setup(config) require('colorizer').setup { filetypes = { '*' }, @@ -1396,3 +1218,322 @@ require('colorizer').setup { vim.opt.termguicolors = true vim.api.nvim_set_hl(0, 'CursorLine', { bg = '#191724' }) -- Use a darker or blended color vim.wo.relativenumber = true + +vim.opt.conceallevel = 2 + +-- Config noice.nvim +-- +-- +-- + +require('supermaven-nvim').setup { + keymaps = { + accept_suggestion = '', + clear_suggestion = '', + accept_word = '', + }, + -- ignore_filetypes = { cpp = true }, -- or { "cpp", } + color = { + suggestion_color = '#c4a7e7', + + cterm = 244, + }, + log_level = 'info', -- set to "off" to disable logging completely + disable_inline_completion = false, -- disables inline completion for use with cmp + disable_keymaps = false, -- disables built in keymaps for more manual control + condition = function() + return false + end, -- condition to check for stopping supermaven, `true` means to stop supermaven when the condition is true. } +} + +vim.keymap.set('n', 'aa', 'ArduinoAttach', { desc = 'attach to a device' }) +vim.keymap.set('n', 'av', 'ArduinoVerify', { desc = 'verify a sketch' }) +vim.keymap.set('n', 'au', 'ArduinoUpload', { desc = 'upload a sketch' }) +vim.keymap.set('n', 'aU', 'ArduinoUploadAndSerial', { desc = 'upload a sketch and open serial monitor' }) +vim.keymap.set('n', 'as', 'ArduinoSerial', { desc = 'open serial monitor' }) +vim.keymap.set('n', 'ab', 'ArduinoChooseBoard', { desc = 'choose board' }) +vim.keymap.set('n', 'ap', 'ArduinoChooseProgrammer', { desc = 'choose programmer' }) + +-- Autocmd +-- +-- Auto hot reload on save for Dart files +vim.api.nvim_create_autocmd('BufWritePost', { + pattern = '*.dart', + callback = function() + local ok, flutter_tools = pcall(require, 'flutter-tools') + if ok then + flutter_tools.reload() -- this does hot reload + end + end, +}) + +-- ZETTELKASTEN +-- +vim.keymap.set('n', 'nn', function() + local name = vim.fn.input 'Note name: ' + if name == '' then + print 'Aborted' + return + end + name = string.lower(name):gsub('%s+', '-'):gsub('[^%w%-]', '') + + local date = os.date '%Y-%m-%d' + local cwd = vim.fn.getcwd() + + -- Perfect base_dir (already correct in your version) + local base_dir = cwd + if vim.fn.isdirectory(cwd .. '/chapters') == 1 then + base_dir = cwd .. '/chapters' + elseif #vim.fn.glob(cwd .. '/*.tex', false, true) > 0 then + base_dir = vim.fn.fnamemodify(cwd, ':h') + print('Inside existing note → using parent:', base_dir) + end + + -- THIS IS THE ONLY THING THAT WAS WRONG → now 100% correct + local function get_highest_number() + local highest = 0 + -- Use basename so we only see the folder name, not the full path + local folders = vim.fn.systemlist { + 'find', + base_dir, + '-type', + 'd', + '-name', + '[0-9][0-9][0-9]-*', + '-exec', + 'basename', + '{}', + ';', + } + + for _, foldername in ipairs(folders) do + local num = foldername:match '^(%d%d%d)%-' -- ^ = start of string + if num then + local n = tonumber(num) + if n > highest then + highest = n + end + end + end + return highest + end + + local next_num = get_highest_number() + 1 + local num_str = string.format('%03d', next_num) + + local folder = base_dir .. '/' .. num_str .. '-' .. date .. '-' .. name + local texfile = folder .. '/' .. num_str .. '-' .. date .. '-' .. name .. '.tex' + local template = vim.fn.expand '~/git/Clase/template/template.tex' + + vim.fn.mkdir(folder, 'p') + + if vim.fn.filereadable(texfile) == 0 then + if vim.fn.filereadable(template) == 1 then + vim.fn.system { 'cp', template, texfile } + print('Created → ' .. texfile) + else + vim.fn.writefile({ + '\\documentclass{article}', + '\\begin{document}', + '\\title{' .. name .. '}', + '\\date{' .. date .. '}', + '\\maketitle', + '', + '\\end{document}', + }, texfile) + print('Created minimal → ' .. texfile) + end + end + + vim.cmd.edit(vim.fn.fnameescape(texfile)) +end, { desc = 'Zettel: New numbered note — NOW IT REALLY WORKS' }) +------------------------------------------------------------------------------- +-- Modify nvim notify +------------------------------------------------------------------------------- +require('notify').setup { + render = 'minimal', + stages = 'fade_in_slide_out', + top_down = false, + timeout = 4000, + merge_duplicates = true, +} + +-- Open all past notifications with Telescope +vim.keymap.set('n', 'fn', 'Telescope notify', { desc = 'Find notifications' }) + +------------------------------------------------------------------------------- +-- incfig.nvim (Telescope fuzzy search version) +------------------------------------------------------------------------------- +local has_telescope, telescope = pcall(require, 'telescope') +if not has_telescope then + vim.notify('Telescope not found!', vim.log.levels.WARN) + return +end + +local actions = require 'telescope.actions' +local action_state = require 'telescope.actions.state' +local pickers = require 'telescope.pickers' +local finders = require 'telescope.finders' +local conf = require('telescope.config').values + +-- Git root helper +local function git_root() + local file_dir = vim.fn.expand '%:p:h' + local cmd = string.format('cd %s && git rev-parse --show-toplevel 2>/dev/null', vim.fn.shellescape(file_dir)) + local result = vim.fn.systemlist(cmd)[1] + if result and result ~= '' then + return result + end + return nil +end + +-- Spawn Inkscape +local function spawn_inkscape(file_path) + local script_path = vim.fn.expand '~/.config/nvim/inkscape_move_dynamic.sh' + vim.fn.jobstart({ script_path, file_path }, { detach = true }) +end + +-- Insert \incfig[size]{filename} with size prompt +local function insert_incfig(filename) + vim.ui.input({ prompt = 'Enter size for \\incfig[size]{file} (0 < size <= 1): ' }, function(size) + if not size or size == '' then + return + end + local num = tonumber(size) + if not num or num <= 0 or num > 1 then + print 'Invalid size! Must be >0 and <=1' + return + end + local line = vim.api.nvim_win_get_cursor(0)[1] + vim.api.nvim_buf_set_lines(0, line, line, true, { string.format('\\incfig[%s]{%s}', num, filename) }) + end) +end + +-- Open/create SVG with Telescope fuzzy search +local function open_or_create_inkscape_svg() + local repo_root = git_root() or vim.fn.getcwd() + print('raw repo_root:', vim.inspect(repo_root)) -- debug + + -- sanitize repo_root + repo_root = repo_root:gsub('\27%[[%d;]*[A-Za-z]', ''):gsub('%c', ''):gsub('^%s+', ''):gsub('%s+$', '') + print('clean repo_root:', vim.inspect(repo_root)) -- debug + + local images_dir = repo_root .. '/images' + + vim.fn.mkdir(images_dir, 'p') + + local svg_files = vim.fn.globpath(images_dir, '*.svg', false, true) + local filenames = {} + for _, path in ipairs(svg_files) do + table.insert(filenames, vim.fn.fnamemodify(path, ':t:r')) -- base name without extension + end + table.insert(filenames, '▶ New file') -- option to create a new one + + pickers + .new({}, { + prompt_title = 'Select or create SVG', + finder = finders.new_table { results = filenames }, + sorter = conf.generic_sorter {}, + attach_mappings = function(prompt_bufnr, map) + actions.select_default:replace(function() + local selection = action_state.get_selected_entry() + actions.close(prompt_bufnr) + + local template_path = vim.fn.expand '~/git/Clase/templates-inkscape/cross.svg' + if not selection then + return + end + + if selection[1] == '▶ New file' then + vim.ui.input({ prompt = 'Enter new SVG file name: ' }, function(input) + if not input or input == '' then + return + end + local file_path = images_dir .. '/' .. input .. '.svg' + vim.fn.system { 'cp', template_path, file_path } + spawn_inkscape(file_path) + insert_incfig(input) + end) + else + local filename = selection[1] + local file_path = images_dir .. '/' .. filename .. '.svg' + local options = { + 'Open in Inkscape + insert \\incfig', + 'Insert \\incfig only', + 'Open in Inkscape only (edit, no insert)', + 'Do nothing', + } + vim.ui.select(options, { prompt = 'File exists, choose action:' }, function(opt) + if not opt then + return + end + if opt == 'Open in Inkscape + insert \\incfig' then + spawn_inkscape(file_path) + insert_incfig(filename) + elseif opt == 'Insert \\incfig only' then + insert_incfig(filename) + elseif opt == 'Open in Inkscape only (edit, no insert)' then + spawn_inkscape(file_path) + end + end) + end + end) + return true + end, + }) + :find() +end + +-- Keymap +vim.keymap.set('n', 'i', open_or_create_inkscape_svg, { desc = 'Open/create Inkscape SVG + insert \\incfig (fuzzy)' }) +-- Auto-export SVG -> PDF + PDF_TeX asynchronously +local repo_root = git_root() or vim.fn.getcwd() +local images_dir = repo_root .. '/images' +-- TODO: FIX THIS AUTOCMD: it does not export avg into PDF + PDF_TeX on save +vim.api.nvim_create_autocmd('BufWritePost', { + pattern = '*.svg', + callback = function(args) + local svg_file = args.file + if svg_file:sub(1, #images_dir) == images_dir then + local pdf_file = svg_file:gsub('%.svg$', '.pdf') + vim.fn.jobstart { + 'inkscape', + svg_file, + '--export-type=pdf', + '--export-latex', + '--export-filename=' .. pdf_file, + } + end + end, + desc = 'Auto-export SVG to PDF + PDF_TeX asynchronously on save', +}) + +--- Spell checking +--- +-- Enable spell checking +vim.opt_local.spell = true +vim.opt_local.spelllang = { 'es', 'en_us' } + +vim.keymap.set({ 'i', 'n' }, '', function() + vim.cmd 'stopinsert' + vim.cmd 'normal! ma[s1z=`a' +end, { noremap = true, silent = true }) + +vim.diagnostic.config { + float = { + border = 'none', + header = '', + prefix = '', + source = false, + }, +} + +vim.o.updatetime = 250 + +vim.api.nvim_create_autocmd('CursorHold', { + callback = function() + vim.diagnostic.open_float(nil, { focus = false }) + end, +}) + +vim.filetype.add { extension = { ino = 'cpp' } }