kickstart.nvim/init.lua             =>           .dotfiles/.config/nvim/init.lua
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
102: 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'

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
136: vim.opt.updatetime = 250 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

-- Decrease mapped sequence wait time
vim.opt.timeoutlen = 300
-- Set completeopt to have a better completion experience
vim.opt.completeopt = 'menuone,noselect'

-- Configure how new splits should be opened
vim.opt.splitright = true
vim.opt.splitbelow = true

-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true

-- Sets how neovim will display certain whitespace characters in the editor.
--  See `:help 'list'`
--  and `:help 'listchars'`
vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
vim.opt.listchars = { tab = '» ', trail = '•', eol = '↵', nbsp = '␣' }

-- Preview substitutions live, as you type!
vim.opt.inccommand = 'split'

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
159: 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 = 6

-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━
173: vim.opt.confirm = true 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
--  See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')

-- nvim-cmp setup for sql stuff
vim.cmd(
  [[autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })]])

-- remove F1 as help page. I have too many accidents
vim.keymap.set({ 'n', 'v', 'i' }, '<F1>' , '<Nop>', { silent = true })
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })

-- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

-- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>do', vim.diagnostic.open_float, { desc = '[D]iagnostics [O]pen float' })
vim.keymap.set('n', '<leader>dd', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })

-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
211: vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' } 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
--  Use CTRL+<hjkl> to switch between windows
--
--  See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
-- vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
-- vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
-- vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })

-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
236: vim.api.nvim_create_autocmd('TextYankPost', { 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  end,
})

vim.cmd([[set guifont=CaskaydiaCove\ NF\ Mono:h26]])

-- [[ Install `lazy.nvim` plugin manager ]]
--    See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
250: if not (vim.uv or vim.loop).fs_stat(lazypath) then 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)

local function grabColor(name, at)
  local tmp = vim.api.nvim_get_hl(0, { name = name })
  return string.format('#%x', tmp[at])
end

local bgColor = "NONE"
local tern = function(cond, t, f)
  if cond then return t else return f end
end

-- helper function for ToggleColor
local winSetHighlights = function(colorSet, accentBgColor, highlightColor)
  vim.api.nvim_set_hl(0, 'Normal', { bg = colorSet })
  vim.api.nvim_set_hl(0, 'NormalFloat', { bg = colorSet })
  vim.api.nvim_set_hl(0, 'NormalNC', { bg = colorSet })
  vim.api.nvim_set_hl(0, 'Cursor', { reverse = true })
  vim.api.nvim_set_hl(0, 'CursorLineNr', { fg = grabColor('Number', 'fg') })
  vim.api.nvim_set_hl(0, 'CursorLine', { bg = tern(bgColor == "NONE", "NONE", accentBgColor) })
  vim.api.nvim_set_hl(0, 'ColorColumn', { bg = tern(bgColor == "NONE", "NONE", accentBgColor) })
  vim.api.nvim_set_hl(0, 'Search', { bg = tern(bgColor == "NONE", "NONE", highlightColor) })
  vim.api.nvim_set_hl(0, 'TabLineFill', { bg = colorSet })
  vim.api.nvim_set_hl(0, 'WinSeparator', { bg = colorSet })
  vim.api.nvim_set_hl(0, 'Folded',
    { fg = grabColor('Folded', 'fg'), bg = tern(bgColor == "NONE", "NONE", accentBgColor) })
end

-- helper function for ToggleColor
local setupLualine = function(colorSet)
  local conditionalColors = {
    visual = { bg = grabColor('Type', 'fg'), fg = colorSet },
    insert = { bg = grabColor('Statement', 'fg') },
    terminal = { bg = grabColor('String', 'fg'), fg = colorSet },
    command = { bg = grabColor('Number', 'fg'), fg = colorSet },
    replace = { bg = grabColor('CurSearch', 'bg'), fg= colorSet },
    normal = { bg = tern(bgColor == "NONE", 'white', "NONE") },
  }

  local function lualine_segment_colors(cols)
    local textCol = tern(cols.fg == nil, "white", cols.fg)
    if bgColor == "NONE" then
      return {
        a = { fg = cols.bg, bg = colorSet, gui = "bold" },
        b = { fg = cols.bg, bg = colorSet },
        c = { bg = colorSet },
        x = { bg = colorSet },
        y = { fg = cols.bg, bg = colorSet },
        z = { fg = cols.bg, bg = colorSet }
      }
    else
      return {
        a = { fg = textCol, bg = cols.bg, gui = "bold" },
        b = { fg = "white", bg = grabColor('WildMenu', 'bg') },
        c = { bg = grabColor('TabLine', 'bg') },
        x = { bg = grabColor('TabLine', 'bg') },
        y = { fg = "white", bg = grabColor('WildMenu', 'bg') },
        z = { fg = textCol, bg = cols.bg }
      }
    end
  end

  local lualine_theme = {}

  for k, v in pairs(conditionalColors) do
    lualine_theme[k] = lualine_segment_colors(v)
  end
  require('lualine').setup {
    options = {
      theme = lualine_theme
    }
  }
end

local _solidBgColor = nil
local solidBgColor = function()
  if _solidBgColor == nil then
    local ok, mod = pcall(require, 'vimbgcol')
    if not ok then
      _solidBgColor = grabColor('Normal', 'bg')
    else
      _solidBgColor = mod
    end
  end

  return _solidBgColor
end
-- Toggles wether or not nvim has transparent background
local ToggleColor = function()
  local accentCol = "NONE"
  local highlightCol = "NONE"
  if bgColor == "NONE" then
    bgColor = solidBgColor()
    local _, _, r, g, b = string.find(bgColor, '^#(%x%x)(%x%x)(%x%x)')
    r, g, b =
        math.floor(tonumber(r, 16)),
        math.floor(tonumber(g, 16)),
        math.floor(tonumber(b, 16))

    accentCol =
        [[#]] ..
        string.format('%02x', math.floor(r * 0.75)) ..
        string.format('%02x', math.floor(g * 0.75)) ..
        string.format('%02x', math.floor(b * 0.75))

    highlightCol =
        [[#]] ..
        string.format('%02x', math.floor(255 * 0.25 + (r * 0.75))) ..
        string.format('%02x', math.floor(255 * 0.25 + (g * 0.75))) ..
        string.format('%02x', math.floor(255 * 0.25 + (b * 0.75)))
  else
    bgColor = "NONE"
  end
  winSetHighlights(bgColor, accentCol, highlightCol)
  setupLualine(bgColor)
end

-- choose your icon chars
local icons = {
  Class = '38;2;248;248;242m,
  Color = '',
  Constant = '',
  Constructor = '',
  Enum = '',
  EnumMember = '',
  Event = '',
  Field = '',
  File = '',
  Folder = '󰉋',
  Function = '󰡱',
  Interface = '',
  Keyword = '',
  Method = "",
  Module = 'mod',
  Operator = '',
  Property = '',
  Reference = 'ref',
  Snippet = '38;2;248;248;242m,
  Struct = '󰘦',
  Text = 'abc',
  TypeParameter = '',
  Unit = '󰑭',
  Value = '',
  Variable = '',
}

-- [[ Configure and install plugins ]]
--
--  To check the current status of your plugins, run

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
416: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
  --

  -- "gc" to comment visual regions/lines
  {
    'numToStr/Comment.nvim',
    opts = {
      opleader = { line = '<leader>com', block = '<leader>bcom' },
    }
  },
  -- Alternatively, use `config = function() ... end` for full control over the configuration.
  -- If you prefer to call `setup` explicitly, use:
  --    {

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
442: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    'lewis6991/gitsigns.nvim',
    opts = {
      signs = {
        add = { text = '+' },
        change = { text = '~' },
        add = { text = '' },
        change = { text = '' },
        delete = { text = '_' },
        topdelete = { text = '‾' },
        changedelete = { text = '~' },
      },
      on_attach = function(bufnr)
        local gs = package.loaded.gitsigns

        local function map(mode, l, r, opts)
          opts = opts or {}
          opts.buffer = bufnr
          vim.keymap.set(mode, l, r, opts)
        end
        -- Actions
        -- visual mode
        map('v', '<leader>ga', function()
          gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
        end, { desc = '[G]it [A]dd/stage hunk' })
        map('v', '<leader>gr', function()
          gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
        end, { desc = '[G]it [R]eset hunk' })
        -- normal mode
        map('n', '<leader>k', gs.prev_hunk, { buffer = bufnr, desc = 'Go to previous Hunk' })
        map('n', '<leader>j', gs.next_hunk, { buffer = bufnr, desc = 'Go to next Hunk' })
        map('n', '<leader>ga', gs.stage_hunk, { buffer = bufnr, desc = '[G]it [A]dd/stage hunk' })
        map('n', '<leader>gA', gs.stage_buffer, { buffer = bufnr, desc = '[G]it add [A]ll hunks in buffer' })
        map('n', '<leader>gu', gs.undo_stage_hunk, { buffer = bufnr, desc = '[G]it [U]ndo hunk' })
        map('n', '<leader>gr', gs.reset_hunk, { buffer = bufnr, desc = '[G]it [R]eset hunk' })
        map('n', '<leader>go', gs.preview_hunk_inline, { buffer = bufnr, desc = '[G]it [O]pen preview of hunk' })
        map('n', '<leader>gc', [[:Git commit<CR>]], { buffer = bufnr, desc = '[G]it [C]ommit' })
        map('n', '<leader>gp', [[:Git push<CR>]], { buffer = bufnr, desc = '[G]it [P]ush' })
        -- Toggles
        map('n', '<leader>gt', gs.toggle_current_line_blame, { buffer = bufnr, desc = '[G]it [T]oggle line blame' })
      end,
    },
  },

  -- Git related plugins
  'tpope/vim-fugitive',
  'tpope/vim-rhubarb',

  { -- git worktree convenient plguin
    'ThePrimeagen/git-worktree.nvim'
  },

  {
    "NeogitOrg/neogit",
    dependencies = {
      "nvim-lua/plenary.nvim",         -- required
      "sindrets/diffview.nvim",        -- optional - Diff integration

      -- Only one of these is needed.
      "nvim-telescope/telescope.nvim", -- optional
      "ibhagwan/fzf-lua",              -- optional
      "echasnovski/mini.pick",         -- optional
    },
    config = true
  },

  -- 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

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
569: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    },
  },

  -- database explorer like PGADmin, but native to NVIM
  'tpope/vim-dadbod',
  -- NOTE: Plugins can specify dependencies.
  --
  -- The dependencies are proper plugin specifications as well - anything

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
578: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  --
  -- Use the `dependencies` key to specify the dependencies of a particular plugin

  -- Remember to install ripgrep in administer terminal `choco install ripgrep`
  { -- Fuzzy Finder (files, lsp, etc)
    'nvim-telescope/telescope.nvim',
    event = 'VimEnter',
    dependencies = {
      'nvim-lua/plenary.nvim',
      'BurntSushi/ripgrep',
      'debugloop/telescope-undo.nvim',
      { -- If encountering errors, see telescope-fzf-native README for installation instructions
        'nvim-telescope/telescope-fzf-native.nvim',


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
605: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
    },
    config = function()
      require("telescope").load_extension("undo")
      vim.keymap.set("n", "<leader>u", [[:Telescope undo<CR>]])
      -- Telescope is a fuzzy finder that comes with a lot of different things that
      -- it can fuzzy find! It's more than just a "file finder", it can search
      -- many different aspects of Neovim, your workspace, LSP, and more!

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
648: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      -- Enable Telescope extensions if they are installed
      pcall(require('telescope').load_extension, 'fzf')
      pcall(require('telescope').load_extension, 'ui-select')
      pcall(require("telescope").load_extension, 'git_worktree')

      -- See `:help telescope.builtin`
      local builtin = require 'telescope.builtin'

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
660: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
      vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
      vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
      vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
      vim.keymap.set('n', '<leader>o', builtin.oldfiles, { desc = 'Search Recently [O]pened files' })
      vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })

      vim.keymap.set('n', '<leader>sr', [[:%s///g<Left><Left><Left>]], { desc = '[S]earch & global [R]eplace' })
      vim.keymap.set('v', '<leader>sr', [[:s///g<Left><Left><Left>]], { desc = '[S]earch & this [L]line [R]eplace' })
      vim.keymap.set('n', '<leader>sa', builtin.git_status, { desc = '[S]earch current [W]ord' })
      -- Slightly advanced example of overriding default behavior and theme
      vim.keymap.set('n', '<leader>/', function()
        -- You can pass additional configuration to Telescope to change the theme, layout, etc.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
677: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

      -- It's also possible to pass additional configuration options.
      --  See `:help telescope.builtin.live_grep()` for information about particular keys
      vim.keymap.set('n', '<leader>s/', function()
      vim.keymap.set('n', '<leader>sG', function()
        builtin.live_grep {
          grep_open_files = true,
          prompt_title = 'Live Grep in Open Files',
        }
      end, { desc = '[S]earch [/] in Open Files' })
      end, { desc = '[S]earch by [G]rep in Open Files!' })

      -- Shortcut for searching your Neovim configuration files
      vim.keymap.set('n', '<leader>sn', function()

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
690: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      end, { desc = '[S]earch [N]eovim files' })
    end,
  },
  -- UI tool for dadbod
  'kristijanhusak/vim-dadbod-ui',

  -- completion tool for dadbod
  'kristijanhusak/vim-dadbod-completion',

  -- LSP Plugins
  -- vim tmux window move intregration
  {
    "christoomey/vim-tmux-navigator",
    cmd = {
      "TmuxNavigateLeft",
      "TmuxNavigateDown",
      "TmuxNavigateUp",
      "TmuxNavigateRight",
      "TmuxNavigatePrevious",
    },
    keys = {
      { "<c-h>",  "<cmd><C-U>TmuxNavigateLeft<cr>" },
      { "<c-j>",  "<cmd><C-U>TmuxNavigateDown<cr>" },
      { "<c-k>",  "<cmd><C-U>TmuxNavigateUp<cr>" },
      { "<c-l>",  "<cmd><C-U>TmuxNavigateRight<cr>" },
      { "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
    },
  },

  { -- LSP Configuration & Plugins
    -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
    -- used for completion, annotations and signatures of Neovim apis
    'folke/lazydev.nvim',

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
789: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

          -- Rename the variable under your cursor.
          --  Most Language Servers support renaming across files, etc.
          map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
          map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')

          -- Execute a code action, usually your cursor needs to be on top of an error
          -- or a suggestion from your LSP for this to activate.
          map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
          map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })

          map('<leader>K', vim.lsp.buf.hover, 'Hover documentation')

          -- Find references for the word under your cursor.
          map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
          map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')

          -- Jump to the implementation of the word under your cursor.
          --  Useful when your language has ways of declaring types without an actual implementation.
          map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
          map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')

          -- Jump to the definition of the word under your cursor.
          --  This is where a variable was first declared, or where a function is defined, etc.
          --  To jump back, press <C-t>.
          map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
          map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')

          -- WARN: This is not Goto Definition, this is Goto Declaration.
          --  For example, in C this would take you to the header.
          map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
          -- map('gd', vim.lsp.buf.declaration, '[G]oto [D]eclaration')

          -- Fuzzy find all the symbols in your current document.
          --  Symbols are things like variables, functions, types, etc.
          map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
          map('<leader>ds', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')

          -- Fuzzy find all the symbols in your current workspace.
          --  Similar to document symbols, except searches over your entire project.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
824: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
          -- Jump to the type of the word under your cursor.
          --  Useful when you're not sure what type a variable is and you want to see
          --  the definition of its *type*, not where it was *defined*.
          map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
          map('gD', require('telescope.builtin').lsp_type_definitions, '[G]oto Type [D]efinition')

          -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
          ---@param client vim.lsp.Client

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
926: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      --        For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
      local servers = {
        -- clangd = {},
        -- gopls = {},
        -- pyright = {},
        -- rust_analyzer = {},
        -- gopls = {}
        pyright = {},
        rust_analyzer = {},
        html = { filetypes = { 'html', 'twig', 'hbs' } },
        eslint = {},
        -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
        --
        -- Some languages (like typescript) have entire language plugins that can be useful:
        --    https://github.com/pmizio/typescript-tools.nvim
        --
        -- But for many setups, the LSP (`ts_ls`) will work just fine
        -- ts_ls = {},
        -- But for many setups, the LSP (`tsserver`) will work just fine
        tsserver = {},
        --

        lua_ls = {

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
950: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                callSnippet = 'Replace',
              },
              -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
              -- diagnostics = { disable = { 'missing-fields' } },
              diagnostics = { disable = { 'missing-fields' } },
            },
          },
        },

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
971: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      -- for you, so that they are available from within Neovim.
      local ensure_installed = vim.tbl_keys(servers or {})
      vim.list_extend(ensure_installed, {
        'stylua', -- Used to format Lua code
        -- 'stylua', -- Used to format Lua code
      })
      require('mason-tool-installer').setup { ensure_installed = ensure_installed }


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
983: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
            local server = servers[server_name] or {}
            -- This handles overriding only values explicitly passed
            -- by the server configuration above. Useful when disabling
            -- certain features of an LSP (for example, turning off formatting for ts_ls)
            -- certain features of an LSP (for example, turning off formatting for tsserver)
            server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
            require('lspconfig')[server_name].setup(server)
          end,

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
992: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    end,
  },

  { -- Autoformat
    'stevearc/conform.nvim',
    event = { 'BufWritePre' },
    cmd = { 'ConformInfo' },
    keys = {
      {
        '<leader>f',
        function()
          require('conform').format { async = true, lsp_format = 'fallback' }
        end,
        mode = '',
        desc = '[F]ormat buffer',
      },
    },
    opts = {
      notify_on_error = false,
      format_on_save = function(bufnr)
        -- 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 }
        if disable_filetypes[vim.bo[bufnr].filetype] then
          return nil
        else
          return {
            timeout_ms = 500,
            lsp_format = 'fallback',
          }
        end
      end,
      formatters_by_ft = {
        lua = { 'stylua' },
        -- Conform can also run multiple formatters sequentially
        -- python = { "isort", "black" },
        --
        -- You can use 'stop_after_first' to run the first available formatter from the list
        -- javascript = { "prettierd", "prettier", stop_after_first = true },
      },
    },
  },

  { -- Autocompletion
    'saghen/blink.cmp',
    event = 'VimEnter',

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1014: 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()
            end,
          },
        },
        opts = {},
      },

      -- Adds other completion capabilities.
      --  nvim-cmp does not ship with all sources by default. They are split
      --  into multiple repos for maintenance purposes.
      'folke/lazydev.nvim',
    },
    --- @module 'blink.cmp'

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1054: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
        -- <c-k>: Toggle signature help
        --
        -- See :h blink-cmp-config-keymap for defining your own keymap
        preset = 'default',
        preset = 'enter',

        -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
        --    https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1094: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      signature = { enabled = true },
    },
  },
  --
  -- Debugger plugin for neovim
  {
    'rcarriga/nvim-dap-ui',
    dependencies = {
      'mfussenegger/nvim-dap',
      'nvim-neotest/nvim-nio',
    },
  },

  -- shows little variable values inline in buffer as the debugger is running
  'theHamsta/nvim-dap-virtual-text',
  { -- You can easily change to a different colorscheme.
    -- Change the name of the colorscheme plugin below, and then
    -- change the command in the config to whatever the name of that colorscheme is.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1168: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
      --  Check out: https://github.com/echasnovski/mini.nvim
    end,
  },

  { -- Highlight, edit, and navigate code
    'nvim-treesitter/nvim-treesitter',
    dependencies = {
      'nvim-treesitter/nvim-treesitter-textobjects',
    },
    build = ':TSUpdate',
    compilers = { "clang" },
    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' },
      -- Add languages to be installed here that you want installed for treesitter
      ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'cpp', 'c_sharp', 'go', 'python', 'rust', 'tsx', 'javascript', 'typescript'},
      -- Autoinstall languages that are not installed
      auto_install = true,
      ignore_install = { "gitcommit", "markdown" },
      highlight = {
        enable = true,
        -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1191: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
        --  the list of additional_vim_regex_highlighting and disabled languages for indent.
        additional_vim_regex_highlighting = { 'ruby' },
      },
      indent = { enable = true, disable = { 'ruby' } },
      indent = { enable = true, disable = { 'ruby', 'html' } },
      textobjects = {
        select = {
          enable = true,
          lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
          keymaps = {
            -- You can use the capture groups defined in textobjects.scm
            ['aa'] = '@parameter.outer',
            ['ia'] = '@parameter.inner',
            ['af'] = '@function.outer',
            ['if'] = '@function.inner',
            ['ac'] = '@class.outer',
            ['ic'] = '@class.inner',
          },
        },
      },
    },
    config = function(_, opts)
      -- [[ Configure Treesitter ]] See `:help nvim-treesitter`

      ---@diagnostic disable-next-line: missing-fields
      require('nvim-treesitter.configs').setup(opts)

      -- 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
    end,
  },

  -- vim commands in the middle of the screen
  {
    'VonHeikemen/fine-cmdline.nvim',
    dependencies = {
      'MunifTanjim/nui.nvim',
    }
  },

  -- Ollama intregration into nvim
  'David-Kunz/gen.nvim',

  -- gives background colors to strings like "#6C7C2D" or "color: darkcyan"
  'brenoprata10/nvim-highlight-colors',

  {
    -- setting the theme
    'catppuccin/nvim',
    priority = 1000,
    lazy = false,
    name = "catppuccin",
    config = function()
      vim.cmd.colorscheme "catppuccin"
      winSetHighlights(bgColor)
    end,
  },

  {
    -- Set lualine as statusline
    'nvim-lualine/lualine.nvim',
    -- See `:help lualine.txt`
    opts = {
      options = {
        icons_enabled = false,
        theme = 'auto',
        component_separators = '',
        section_separators = '',
      },
      sections = {
        lualine_a = { 'filename' },
        lualine_b = { 'filetype' },
        lualine_c = { 'diagnostics' },
        lualine_x = { 'diff' },
        lualine_y = { 'branch' },
        lualine_z = { 'fileformat', 'encoding' }
      },
      inactive_sections = {
        lualine_a = { 'filename' },
        lualine_b = {},
        lualine_c = {},
        lualine_x = {},
        lualine_y = {},
        lualine_z = { 'filetype' }
      }
    },
    -- 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:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1285: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    --    - 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
  {
    -- Add indentation guides even on blank lines
    'lukas-reineke/indent-blankline.nvim',
    -- Enable `lukas-reineke/indent-blankline.nvim`
    -- See `:help ibl`
    main = 'ibl',
    opts = {},
  },


  -- tag completion for html tags or react components starting with <something
  {
    'windwp/nvim-ts-autotag',
    ft = {
      'javascript',
      'javascriptreact',
      'typescript',
      'typescriptreact',
    },
    config = function()
      require('nvim-ts-autotag').setup()
    end
  },

  {
    "nvim-telescope/telescope-file-browser.nvim",
    dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }
  },

  "Asheq/close-buffers.vim",

  -- code runner for inline feedback for interpreted languages like js, python and lua
  {
    -- '0x100101/lab.nvim' fork
    'Edvid/lab.nvim',
    build = 'cd js && npm ci',
    dependencies = {
      'nvim-lua/plenary.nvim',
    },
  },

  {
    'whonore/Coqtail'
  }

  -- The following two 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
  -- place them in the correct locations.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1361: require('lazy').setup({ 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    -- If you are using a Nerd Font: set icons to an empty table which will use the
    -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
    icons = vim.g.have_nerd_font and {} or {
      cmd = '⌘',
      config = '0m
      event = '📅',
      ft = '📂',
      init = '⚙',
      keys = '🗝',
      plugin = '🔌',
      runtime = '💻',
      require = '🌙',
      source = '📄',
      start = '🚀',
      task = '📌',
      lazy = '💤 ',
      -- cmd = '⌘',
      -- config = '0m
      -- event = '📅',
      -- ft = '📂',
      -- init = '⚙',
      -- keys = '🗝',
      -- plugin = '🔌',
      -- runtime = '💻',
      -- require = '🌙',
      -- source = '📄',
      -- start = '🚀',
      -- task = '📌',
      -- lazy = '💤 ',
    },
  },
})


require('ibl').setup {
  indent = { char = "┆" },
}


-- local lualine_theme = require('lualine.themes.auto')
vim.schedule(function()
  vim.cmd.colorscheme "catppuccin"
  setupLualine()
end)

require('lab').setup {}
-- See `:help telescope.builtin`

require('nvim-highlight-colors').turnOn()

-- Diagnostic keymaps
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })

-- quit nvim dap floats with q
vim.api.nvim_create_autocmd('filetype', {
  pattern = 'dap-float',
  desc = 'quit floats with q',
  callback = function()
    vim.keymap.set('n', 'q', '<C-w>q', { remap = true, buffer = true })
  end
})
--
-- Debugger keymaps
require('dapui').setup()

require('fine-cmdline').setup({
  popup = {
    position = {
      row = '50%',
    },
    size = { width = '40%' },
  }
})

-- keybind for fine-cmdline
vim.api.nvim_set_keymap('n', 'æ', '<cmd>FineCmdline<CR>', { noremap = true })
vim.api.nvim_set_keymap('v', 'æ', '<cmd>FineCmdline\'<,\'><CR>', { noremap = true })

require("git-worktree").setup({
  clearjumps_on_change = false -- default: true
})
vim.keymap.set('n', '<leader>wt<leader>', require('telescope').extensions.git_worktree.git_worktrees, { desc = '[W]ork [T]ree list all' })
vim.keymap.set('n', '<leader>wtc', require('telescope').extensions.git_worktree.create_git_worktree, { desc = '[W]ork [T]ree [C]reate' })

require('gen').setup({
  model = "mistral",
  display_mode = "split",
  show_prompt = true,
  show_model = true,
  no_auto_close = false,
  init = function(options) pcall(io.popen, "ollama serve > /dev/null 2>&1 &") end,
  command = "curl --silent --no-buffer -X POST http://localhost:11434/api/generate -d $body",
})

-- gen.nvim keybind
vim.keymap.set({ 'n', 'v' }, '<leader>Gch', [[:Gen Chat<CR>]], { desc = [[using [Gen] [ch]at with AI]] })
vim.keymap.set('v', '<leader>Gcc', [[:Gen Change_Code<CR>]], { desc = [[using [Gen], [C]hange [C]ode with AI]] })

-- Setup neovim lua configuration
require('lazydev').setup()

-- Mason doesn't work well with gdscript, so we will setup manually
local dap = require('dap')
dap.adapters.godot = {
  type = 'server',
  host = '127.0.0.1',
  port = 6006,
}

dap.configurations.gdscript = {
  {
    type = 'godot',
    request = 'launch',
    name = 'Launch scene',
    project = '${workspaceFolder}',
    launch_scene = true,
  }
}

vim.keymap.set('n', '<leader>dt', require('dapui').toggle, { desc = '[D]ebugger [T]oggle' })
vim.keymap.set('n', '<leader>db', [[:DapToggleBreakpoint<CR>]], { desc = '[D]ebugger toggle [B]reakpoint' })
vim.keymap.set('n', '<Leader>dr', dap.continue, { desc = '[D]ebugger [R]un or continue'} )
vim.keymap.set('n', '<Leader>dc', function()
  dap.terminate()
  require('dapui').close()
end , { desc = '[D]ebugger [C]lose'} )
vim.keymap.set('n', '<leader>d<C-J>', dap.step_over, { desc = '[D]ebugger DOWN (step over)' })
vim.keymap.set('n', '<leader>d<C-L>', dap.step_into, { desc = '[D]ebugger RIGHT (step into)' })
vim.keymap.set('n', '<leader>d<C-H>', dap.step_out, { desc = '[D]ebugger LEFT (step out)' })
vim.keymap.set({'n', 'v'}, '<Leader>dh', function()
  require('dap.ui.widgets').hover()
end, { desc = '[D]ebugger [H]over'})

local gdscript = (function()
  local port = os.getenv 'GDScript_Port' or '6005'
  local cmd = vim.lsp.rpc.connect('127.0.0.1', tonumber(port))
  return {
    cmd = cmd,
    filetypes = { 'gd', 'gdscript', 'gdscript3' },
    root_markers = { 'project.godot', '.git' },
  }
end)()
vim.lsp.enable('gdscript')
vim.lsp.config('gdscript', gdscript)
-- require('lspconfig').gdscript.setup { gdscript }

require("telescope").setup {
  extensions = {
    file_browser = {
      previewer = false,
      depth = 1,
      hidden = { file_browser = true, folder_browser = true },
      theme = "ivy",
      -- disables netrw and use telescope-file-browser in its place
      hijack_netrw = true,
      mappings = {
        ["i"] = {
          -- your custom insert mode mappings
        },
        ["n"] = {
          -- your custom normal mode mappings
        },
      },
    },
  },
}

require("telescope").load_extension "file_browser"

vim.opt.showmode = false

vim.cmd([[set cursorline]])

vim.cmd([[au BufRead,BufNewFile * set sw=0]])
vim.cmd([[au BufRead,BufNewFile * set ts=2]])
vim.cmd([[au BufRead,BufNewFile * set expandtab]])
vim.cmd([[au BufRead,BufNewFile */COMMIT_EDITMSG set cc=70]])

local function tick_checkboxes(startline, endline)
  for lineindex = startline, endline do
    local thisline = vim.api.nvim_buf_get_lines(0, lineindex - 1, lineindex, true)[1]
    local search_and_replace

    if
      string.find(thisline, "^ *%[X%]") or
      string.find(thisline, "^ *- %[X%]") then
      search_and_replace = lineindex .. [[s/\[X\]/\[ \]/]]
    elseif
      string.find(thisline, "^ *%[ %]") or
      string.find(thisline, "^ *- %[ %]") then
      search_and_replace = lineindex .. [[s/\[ \]/\[X\]/]]
    else
      goto continue
    end

    vim.cmd([[execute "normal" "mz"]])
    vim.cmd(search_and_replace)
    vim.cmd([[nohlsearch]])
    vim.cmd([[execute "normal" "`z"]])
    ::continue::
  end
end

vim.keymap.set({ 'n' }, 'X', function()
  local linenum = vim.fn.getcurpos()[2]
  tick_checkboxes(linenum, linenum)
end)
vim.keymap.set({ 'v' }, 'X', function()
  local start_sel = vim.fn.getpos([[.]])[2]
  local end_sel = vim.fn.getpos([[v]])[2]
  tick_checkboxes(
    math.min(start_sel, end_sel),
    math.max(start_sel, end_sel)
  )
end)

vim.schedule(function()
  ToggleColor()
end)

vim.api.nvim_create_user_command("ToggleTransparency", function()
  ToggleColor()
end, {})

vim.keymap.set('n', '<leader>xx', [[:source ~/.config/nvim/init.lua<CR>]], { desc = 'source/E[X]ecute init' })
vim.keymap.set('n', '<leader>xt', [[:source %<CR>]], { desc = 'source/E[X]ecute [T]his' })

-- Toggle between always having the cursor centered and not doing so
local fixedLines = false

local function toggleFixedLines()
  if fixedLines then
    vim.opt.scrolloff = 6
  else
    vim.opt.scrolloff = 9999
  end
  fixedLines = not fixedLines
end

vim.keymap.set('n', '<leader>l', toggleFixedLines, { desc = 'fixed [L]ines' })

-- paste without destroying what you have in register
vim.keymap.set('v', '<leader>p', [["_dP]], { noremap = true, desc = [[[P]aste without loosing clipboard]] })

-- new file here and explore here keybinds
vim.keymap.set('n', '<leader>n', [[:FineCmdline edit %:p:h/<CR>]], { desc = [[edit/create [N]ew file here]] })
vim.keymap.set('n', '<leader>e', [[:Telescope file_browser<CR>]], { desc = [[[E]xplore from here]] })

vim.api.nvim_create_user_command("W",
  [[:w|silent !prettier % --write]], { desc = [[save and format with prettier]]}
)

-- better keybinds for netrw
vim.api.nvim_create_autocmd('filetype', {
  pattern = 'netrw',
  desc = 'Better keybinds for netrw',
  callback = function()
    local bind = function(new, old)
      vim.keymap.set('n', new, old, { remap = true, buffer = true })
    end

    -- edit new file
    bind('<leader>n', '%')

    -- rename file
    bind('r', 'R')
  end
})

vim.keymap.set({ 'n', 'i', 'v', 'o', 'c' }, '<A-s>', ToggleColor)

vim.api.nvim_set_hl(0, "TreesitterContextLineNumber", { fg = [[#9CB8FF]] })

vim.keymap.set('n', '<leader>who', [[:G blame<CR>]])
vim.keymap.set('n', '<leader>cl', [[:Bd other<CR>]])
vim.keymap.set('n', '<leader>col', [[:FineCmdline set cc=<CR>]], { desc = 'Color in [COL]umn at given number' })
vim.keymap.set('n', '<leader>gd', [[:Gdiff!<CR>]], { desc = 'Fu[git]ive [d]iff'} )
-- NOTE: vim has a native mapping 'dp' for :diffput
vim.keymap.set('n', '<leader>gk', [[:diffget //2<CR>]], { desc = 'diffget grab up'} )
vim.keymap.set('n', '<leader>gj', [[:diffget //3<CR>]], { desc = 'diffget grab down'} )

vim.keymap.set('n', '<leader>run', [[:Lab code run<CR>]], { desc = '[RUN] lab code runner' })
vim.keymap.set('n', '<leader>stop', [[:Lab code stop<CR>]], { desc = '[STOP] lab code runner' })

vim.keymap.set({ 'n', 'v' }, '<leader>f', [[/]])
vim.keymap.set({ 'n', 'v' }, '<leader>q', [[@]])

vim.keymap.set('n', 'gp', '`[v`]', { desc = "Reselect last pasted" })

vim.keymap.set('n', '<leader>J', [[mz<cmd>join<CR>`z]])

vim.keymap.set('n', 'J', [[:m +1<CR>==]])
vim.keymap.set('n', 'K', [[:m -2<CR>==]])
vim.keymap.set('v', 'K', [[:m '<-2<CR>gv=gv]])
vim.keymap.set('v', 'J', [[:m '>+1<CR>gv=gv]])

vim.keymap.set('n', '<leader>ck', [[:cprev<CR>]])
vim.keymap.set('n', '<leader>cj', [[:cnext<CR>]])

vim.keymap.set('v', '<leader>_', [[:norm! _]])

vim.keymap.set('n', '<A-d>', [[:bn<CR>]])
vim.keymap.set('n', '<A-a>', [[:bN<CR>]])
vim.keymap.set({ 'n', 'v', 'o', 'c' }, '<C-z>', '<Nop>')

vim.cmd([[set rtp^="/home/space/.opam/default/share/ocp-indent/vim"]])

vim.opt.wrap = true
vim.opt.linebreak = true

-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et