diff options
| author | Daniil Rozanov <dev@drozanov.info> | 2024-11-11 10:28:46 +0400 | 
|---|---|---|
| committer | Daniil Rozanov <dev@drozanov.info> | 2024-11-11 10:28:46 +0400 | 
| commit | c7e9ba4c96f73b650d5a1831f934ddac90cd019a (patch) | |
| tree | 90e79c9a0d3d708f2937373c2b2d555c42cdd77a /nvim | |
| parent | 2262cbc7f4d6d05ce4932af8b586ea8455361eda (diff) | |
neovim init
Diffstat (limited to 'nvim')
49 files changed, 904 insertions, 0 deletions
| diff --git a/nvim/.config/nvim/after/ftplugin/dbui.lua b/nvim/.config/nvim/after/ftplugin/dbui.lua new file mode 100644 index 0000000..dccca2f --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/dbui.lua @@ -0,0 +1,4 @@ +local opt = vim.opt_local + +opt.shiftwidth = 2 +opt.cursorline = true diff --git a/nvim/.config/nvim/after/ftplugin/sql.lua b/nvim/.config/nvim/after/ftplugin/sql.lua new file mode 100644 index 0000000..cb4775f --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/sql.lua @@ -0,0 +1 @@ +vim.opt_local.commentstring = "-- %s" diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..d3ebf8f --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,25 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +if not vim.uv.fs_stat(lazypath) then +  vim.fn.system { +    "git", +    "clone", +    "--filter=blob:none", +    "https://github.com/folke/lazy.nvim.git", +    "--branch=stable", +    lazypath, +  } +end + +-- Add lazy to the `runtimepath`, this allows us to `require` it. +---@diagnostic disable-next-line: undefined-field +vim.opt.rtp:prepend(lazypath) + +-- Set up lazy, and load my `lua/custom/plugins/` folder +require("lazy").setup({ import = "custom/plugins" }, { +  change_detection = { +    notify = false, +  }, +}) diff --git a/nvim/.config/nvim/lua/custom/autopairs.lua b/nvim/.config/nvim/lua/custom/autopairs.lua new file mode 100644 index 0000000..00c7812 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/autopairs.lua @@ -0,0 +1,5 @@ +require("nvim-autopairs").setup {} +-- Automatically add `(` after selecting a function or method +local cmp_autopairs = require "nvim-autopairs.completion.cmp" +local cmp = require "cmp" +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) diff --git a/nvim/.config/nvim/lua/custom/cmake.lua b/nvim/.config/nvim/lua/custom/cmake.lua new file mode 100644 index 0000000..bef1fc7 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/cmake.lua @@ -0,0 +1 @@ +require("cmake").setup { cmake = { parallel_jobs = #vim.uv.cpu_info() } } diff --git a/nvim/.config/nvim/lua/custom/cmp.lua b/nvim/.config/nvim/lua/custom/cmp.lua new file mode 100644 index 0000000..5cbb2e8 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/cmp.lua @@ -0,0 +1,69 @@ +vim.opt.completeopt = { "menu", "menuone", "noselect" } +vim.opt.shortmess:append "c" + +local lspkind = require "lspkind" +lspkind.init {} + +local luasnip = require "luasnip" +luasnip.config.setup {} +require("luasnip.loaders.from_vscode").lazy_load() + +local cmp = require "cmp" + +cmp.setup { +  snippet = { +    expand = function(args) +      luasnip.lsp_expand(args.body) +    end, +  }, +  completion = { completeopt = "menu,menuone,noinsert" }, +  mapping = cmp.mapping.preset.insert { +    -- ["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, +    -- ["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, +    ["<C-y>"] = cmp.mapping( +      cmp.mapping.confirm { +        behavior = cmp.ConfirmBehavior.Insert, +        select = true, +      }, +      { "i", "c" } +    ), +    ["<C-b>"] = cmp.mapping.scroll_docs(-4), +    ["<C-f>"] = cmp.mapping.scroll_docs(4), +    -- ["<C-y>"] = cmp.mapping.confirm { select = true }, +    --   -- Will move you to the right of each of the snippet's expansion locations. +    ["<C-l>"] = cmp.mapping(function() +      if luasnip.expand_or_locally_jumpable() then +        luasnip.expand_or_jump() +      end +    end, { "i", "s" }), +    -- Will move you to the left of each of the snippet's expansion locations. +    ["<C-h>"] = cmp.mapping(function() +      if luasnip.locally_jumpable(-1) then +        luasnip.jump(-1) +      end +    end, { "i", "s" }), +  }, +  sources = { +    { name = "nvim_lsp" }, +    { name = "luasnip" }, +    { name = "path" }, +    { name = "buffer" }, +  }, +} + +-- Setup up vim-dadbod +cmp.setup.filetype({ "sql" }, { +  sources = { +    { name = "vim-dadbod-completion" }, +    { name = "buffer" }, +  }, +}) + +luasnip.config.set_config { +  history = false, +  updateevents = "TextChanged,TextChangedI", +} + +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/custom/snippets/*.lua", true)) do +  loadfile(ft_path)() +end diff --git a/nvim/.config/nvim/lua/custom/gitsigns.lua b/nvim/.config/nvim/lua/custom/gitsigns.lua new file mode 100644 index 0000000..2a12ebb --- /dev/null +++ b/nvim/.config/nvim/lua/custom/gitsigns.lua @@ -0,0 +1,60 @@ +local gitsigns = require "gitsigns" + +local on_attach = function(bufnr) +  local function map(mode, l, r, opts) +    opts = opts or {} +    opts.buffer = bufnr +    vim.keymap.set(mode, l, r, opts) +  end + +  -- Navigation +  map("n", "]c", function() +    if vim.wo.diff then +      vim.cmd.normal { "]c", bang = true } +    else +      gitsigns.nav_hunk "next" +    end +  end) + +  map("n", "[c", function() +    if vim.wo.diff then +      vim.cmd.normal { "[c", bang = true } +    else +      gitsigns.nav_hunk "prev" +    end +  end) + +  -- Actions +  map("n", "<leader>gs", gitsigns.stage_hunk, { desc = "Stage hunk" }) +  map("n", "<leader>gr", gitsigns.reset_hunk, { desc = "Reset hunk" }) +  map("v", "<leader>gs", function() +    gitsigns.stage_hunk { vim.fn.line ".", vim.fn.line "v" } +  end, { desc = "Stage hunk" }) +  map("v", "<leader>gr", function() +    gitsigns.reset_hunk { vim.fn.line ".", vim.fn.line "v" } +  end, { desc = "Reset hunk" }) +  map("n", "<leader>gS", gitsigns.stage_buffer, { desc = "Stage buffer" }) +  map("n", "<leader>gu", gitsigns.undo_stage_hunk, { desc = "Undo stage hunk" }) +  map("n", "<leader>gR", gitsigns.reset_buffer, { desc = "Reset buffer" }) +  map("n", "<leader>gp", gitsigns.preview_hunk, { desc = "Preview hunk" }) +  map("n", "<leader>gb", function() +    gitsigns.blame_line { full = true } +  end, { desc = "Blame line" }) +  map("n", "<leader>Tb", gitsigns.toggle_current_line_blame, { desc = "Toggle blame line" }) +  map("n", "<leader>Td", gitsigns.toggle_deleted, { desc = "Toggle deleted" }) +  map("n", "<leader>gd", gitsigns.diffthis, { desc = "Diff this" }) +  map("n", "<leader>gD", function() +    gitsigns.diffthis "~" +  end, { desc = "Diff this ~" }) +end + +gitsigns.setup { +  signs = { +    add = { text = "+" }, +    change = { text = "~" }, +    delete = { text = "_" }, +    topdelete = { text = "‾" }, +    changedelete = { text = "~" }, +  }, +  on_attach = on_attach, +} diff --git a/nvim/.config/nvim/lua/custom/harpoon.lua b/nvim/.config/nvim/lua/custom/harpoon.lua new file mode 100644 index 0000000..06a20d7 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/harpoon.lua @@ -0,0 +1,25 @@ +local harpoon = require "harpoon" +harpoon:setup() + +vim.keymap.set("n", "<leader>a", function() +  harpoon:list():add() +end) + +vim.keymap.set("n", "<leader><leader>", function() +  harpoon.ui:toggle_quick_menu(harpoon:list()) +end) + +vim.keymap.set("n", "<c-n>", function() +  require("harpoon"):list():next() +end) + +vim.keymap.set("n", "<c-p>", function() +  require("harpoon"):list():prev() +end) + +-- Set <space>1..<space>5 be my shortcuts to moving to the files +for _, idx in ipairs { 1, 2, 3, 4, 5 } do +  vim.keymap.set("n", string.format("<leader>%d", idx), function() +    harpoon:list():select(idx) +  end) +end diff --git a/nvim/.config/nvim/lua/custom/init.lua b/nvim/.config/nvim/lua/custom/init.lua new file mode 100644 index 0000000..9e39d84 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/init.lua @@ -0,0 +1,5 @@ +require("chell.globals") +require("chell.options") +require("chell.keymaps") +require("chell.autocmds") +require("chell.lazy") diff --git a/nvim/.config/nvim/lua/custom/leap.lua b/nvim/.config/nvim/lua/custom/leap.lua new file mode 100644 index 0000000..5f25e50 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/leap.lua @@ -0,0 +1,3 @@ +vim.keymap.set("n", "s", "<Plug>(leap)", { desc = "Leap" }) +vim.keymap.set("n", "S", "<Plug>(leap-from-window)", { desc = "Leap other window" }) +require("leap").setup { safe_labels = {} } diff --git a/nvim/.config/nvim/lua/custom/lsp.lua b/nvim/.config/nvim/lua/custom/lsp.lua new file mode 100644 index 0000000..0944ff5 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/lsp.lua @@ -0,0 +1,134 @@ +--TODO: make it prettier + +require("neodev").setup { +  library = { +    plugins = { "nvim-dap-ui" }, +    types = true, +  }, +} + +local capabilities = nil +if pcall(require, "cmp_nvim_lsp") then +  capabilities = require("cmp_nvim_lsp").default_capabilities() +end + +local lspconfig = require "lspconfig" + +local servers = { +  bashls = true, +  gopls = true, +  lua_ls = true, +  rust_analyzer = true, + +  jsonls = { +    settings = { +      json = { +        schemas = require("schemastore").json.schemas(), +        validate = { enable = true }, +      }, +    }, +  }, + +  yamlls = { +    settings = { +      yaml = { +        schemaStore = { +          enable = false, +          url = "", +        }, +        schemas = require("schemastore").yaml.schemas(), +      }, +    }, +  }, + +  clangd = { +    init_options = { clangdFileStatus = true }, +  }, +} + +local servers_to_install = vim.tbl_filter(function(key) +  local t = servers[key] +  if type(t) == "table" then +    return not t.manual_install +  else +    return t +  end +end, vim.tbl_keys(servers)) + +require("mason").setup() +local ensure_installed = { +  "stylua", +  "lua_ls", +  "clangd", +  "clang-format", +  "neocmake", +} + +vim.list_extend(ensure_installed, servers_to_install) +require("mason-tool-installer").setup { ensure_installed = ensure_installed } + +for name, config in pairs(servers) do +  if config == true then +    config = {} +  end +  config = vim.tbl_deep_extend("force", {}, { +    capabilities = capabilities, +  }, config) + +  lspconfig[name].setup(config) +end + +local disable_semantic_tokens = { +  lua = true, +} + +vim.api.nvim_create_autocmd("LspAttach", { +  callback = function(args) +    local bufnr = args.buf +    local client = assert(vim.lsp.get_client_by_id(args.data.client_id), "must have valid client") +    local builtin = require "telescope.builtin" + +    vim.opt_local.omnifunc = "v:lua.vim.lsp.omnifunc" +    vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = 0 }) +    vim.keymap.set("n", "gr", vim.lsp.buf.references, { buffer = 0 }) +    vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = 0 }) +    vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, { buffer = 0 }) +    vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, { buffer = 0 }) +    vim.keymap.set("n", "<leader>la", vim.lsp.buf.code_action, { buffer = 0 }) +    vim.keymap.set("n", "<leader>ls", builtin.lsp_document_symbols, { desc = "[D]ocument [S]ymbols" }) +    vim.keymap.set("n", "<leader>lw", builtin.lsp_dynamic_workspace_symbols, { desc = "[W]orkspace Symbols" }) +    -- nmap("gd", builtin.lsp_definitions, { desc = "[G]oto [D]efinition" }) +    -- nmap("gr", builtin.lsp_references, { desc = "[G]oto [R]eferences" }) +    -- nmap("gI", builtin.lsp_implementations, { desc = "[G]oto [I]mplementation" }) + +    local filetype = vim.bo[bufnr].filetype +    if disable_semantic_tokens[filetype] then +      client.server_capabilities.semanticTokensProvider = nil +    end + +    if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then +      vim.keymap.set("n", "<leader>Th", function() +        vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) +      end, { desc = "[T]oggle Inlay [H]ints" }) +    end +  end, +}) + +-- Autoformatting Setup +require("conform").setup { +  formatters_by_ft = { +    lua = { "stylua" }, +    cpp = { "clang-format" }, +    c = { "clang-format" }, +  }, +} + +vim.api.nvim_create_autocmd("BufWritePre", { +  callback = function(args) +    require("conform").format { +      bufnr = args.buf, +      lsp_fallback = true, +      quiet = true, +    } +  end, +}) diff --git a/nvim/.config/nvim/lua/custom/mini.lua b/nvim/.config/nvim/lua/custom/mini.lua new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/mini.lua diff --git a/nvim/.config/nvim/lua/custom/plugins/autopairs.lua b/nvim/.config/nvim/lua/custom/plugins/autopairs.lua new file mode 100644 index 0000000..170b337 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/autopairs.lua @@ -0,0 +1,9 @@ +return { +  "windwp/nvim-autopairs", +  event = "InsertEnter", +  -- Optional dependency +  dependencies = { "hrsh7th/nvim-cmp" }, +  config = function() +    require "custom.autopairs" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/bqf.lua b/nvim/.config/nvim/lua/custom/plugins/bqf.lua new file mode 100644 index 0000000..92630a8 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/bqf.lua @@ -0,0 +1 @@ +return { "kevinhwang91/nvim-bqf", ft = "qf" } diff --git a/nvim/.config/nvim/lua/custom/plugins/celluar.lua b/nvim/.config/nvim/lua/custom/plugins/celluar.lua new file mode 100644 index 0000000..f90161e --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/celluar.lua @@ -0,0 +1 @@ +return { "Eandrju/cellular-automaton.nvim" } diff --git a/nvim/.config/nvim/lua/custom/plugins/cmake.lua b/nvim/.config/nvim/lua/custom/plugins/cmake.lua new file mode 100644 index 0000000..8bd0207 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/cmake.lua @@ -0,0 +1,17 @@ +if vim.loop.os_uname().sysname ~= "Darwin" then +  return { +    "daniilrozanov/cmake.nvim", +    lazy = false, +    config = function() +      require "custom.cmake" +    end, +  } +else +  return { +    dir = "~/repositories/cmake.nvim", +    lazy = false, +    config = function() +      require "custom.cmake" +    end, +  } +end diff --git a/nvim/.config/nvim/lua/custom/plugins/cmp.lua b/nvim/.config/nvim/lua/custom/plugins/cmp.lua new file mode 100644 index 0000000..83fb5a2 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/cmp.lua @@ -0,0 +1,22 @@ +return { +  { +    "hrsh7th/nvim-cmp", +    event = "InsertEnter", +    priority = 100, +    dependencies = { +      "onsails/lspkind.nvim", +      "hrsh7th/cmp-nvim-lsp", +      "hrsh7th/cmp-path", +      "hrsh7th/cmp-buffer", +      { +        "L3MON4D3/LuaSnip", +        build = "make install_jsregexp", +        dependencies = { "rafamadriz/friendly-snippets" }, +      }, +      "saadparwaiz1/cmp_luasnip", +    }, +    config = function() +      require "custom.cmp" +    end, +  }, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/comment.lua b/nvim/.config/nvim/lua/custom/plugins/comment.lua new file mode 100644 index 0000000..46f5032 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/comment.lua @@ -0,0 +1 @@ +return { 'numToStr/Comment.nvim' } diff --git a/nvim/.config/nvim/lua/custom/plugins/conform.lua b/nvim/.config/nvim/lua/custom/plugins/conform.lua new file mode 100644 index 0000000..542434e --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/conform.lua @@ -0,0 +1,36 @@ +return { -- Autoformat +  "stevearc/conform.nvim", +  lazy = false, +  keys = { +    { +      "<leader>lf", +      function() +        require("conform").format({ async = true, lsp_fallback = true }) +      end, +      mode = "", +      desc = "Format 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 } +      return { +        timeout_ms = 500, +        lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], +      } +    end, +    formatters_by_ft = { +      lua = { "stylua" }, +      -- Conform can also run multiple formatters sequentially +      -- python = { "isort", "black" }, +      -- +      -- You can use a sub-list to tell conform to run *until* a formatter +      -- is found. +      -- javascript = { { "prettierd", "prettier" } }, +    }, +  }, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/dadbod.lua b/nvim/.config/nvim/lua/custom/plugins/dadbod.lua new file mode 100644 index 0000000..8411fa5 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/dadbod.lua @@ -0,0 +1,16 @@ +return { +  "kristijanhusak/vim-dadbod-ui", +  dependencies = { +    { "tpope/vim-dadbod", lazy = true }, +    { "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true }, +  }, +  cmd = { +    "DBUI", +    "DBUIToggle", +    "DBUIAddConnection", +    "DBUIFindBuffer", +  }, +  init = function() +    vim.g.db_ui_use_nerd_fonts = 1 +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/gitsigns.lua b/nvim/.config/nvim/lua/custom/plugins/gitsigns.lua new file mode 100644 index 0000000..3da8ed4 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/gitsigns.lua @@ -0,0 +1,6 @@ +return { +  "lewis6991/gitsigns.nvim", +  config = function() +    require "custom.gitsigns" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/harpoon.lua b/nvim/.config/nvim/lua/custom/plugins/harpoon.lua new file mode 100644 index 0000000..aa8dae8 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/harpoon.lua @@ -0,0 +1,8 @@ +return { +  "ThePrimeagen/harpoon", +  branch = "harpoon2", +  dependencies = { "nvim-lua/plenary.nvim" }, +  config = function() +    require "custom.harpoon" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/leap.lua b/nvim/.config/nvim/lua/custom/plugins/leap.lua new file mode 100644 index 0000000..5566ecc --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/leap.lua @@ -0,0 +1,7 @@ +return { +  "ggandor/leap.nvim", +  lazy = false, --TODO: lazy +  config = function() +    require "custom.leap" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/lsp.lua b/nvim/.config/nvim/lua/custom/plugins/lsp.lua new file mode 100644 index 0000000..ac87b84 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/lsp.lua @@ -0,0 +1,22 @@ +return { +  { +    "neovim/nvim-lspconfig", +    dependencies = { +      "folke/neodev.nvim", +      "williamboman/mason.nvim", +      "williamboman/mason-lspconfig.nvim", +      "WhoIsSethDaniel/mason-tool-installer.nvim", + +      { "j-hui/fidget.nvim", opts = {} }, + +      -- Autoformatting +      "stevearc/conform.nvim", + +      -- Schema information +      "b0o/SchemaStore.nvim", +    }, +    config = function() +      require "custom.lsp" +    end, +  }, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/lualine.lua b/nvim/.config/nvim/lua/custom/plugins/lualine.lua new file mode 100644 index 0000000..661f7fc --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/lualine.lua @@ -0,0 +1,5 @@ +return { +  "nvim-lualine/lualine.nvim", +  dependencies = { "nvim-tree/nvim-web-devicons" }, +  config = true, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/mini.lua b/nvim/.config/nvim/lua/custom/plugins/mini.lua new file mode 100644 index 0000000..654222e --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/mini.lua @@ -0,0 +1,8 @@ +return { -- Collection of various small independent plugins/modules +  "echasnovski/mini.nvim", +  dependencies = "nvim-treesitter/nvim-treesitter", +  config = function() +    -- Better Around/Inside textobjects +    require("mini.ai").setup { n_lines = 500 } +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/rest.lua b/nvim/.config/nvim/lua/custom/plugins/rest.lua new file mode 100644 index 0000000..2d53a70 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/rest.lua @@ -0,0 +1,16 @@ +return { +  { +    "vhyrro/luarocks.nvim", +    priority = 1000, +    config = true, +    opts = { rocks = { "lua-curl", "nvim-nio", "mimetypes", "xml2lua" } }, +  }, +  { +    "rest-nvim/rest.nvim", +    ft = "http", +    dependencies = { "luarocks.nvim", "nvim-treesitter/nvim-treesitter" }, +    config = function() +      require "custom.rest" +    end, +  }, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/sort.lua b/nvim/.config/nvim/lua/custom/plugins/sort.lua new file mode 100644 index 0000000..f5483e6 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/sort.lua @@ -0,0 +1 @@ +return { "sQVe/sort.nvim" } diff --git a/nvim/.config/nvim/lua/custom/plugins/substitude.lua b/nvim/.config/nvim/lua/custom/plugins/substitude.lua new file mode 100644 index 0000000..bb8bd9f --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/substitude.lua @@ -0,0 +1,6 @@ +return { +  "gbprod/substitute.nvim", +  config = function() +    require "custom.substitude" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/surround.lua b/nvim/.config/nvim/lua/custom/plugins/surround.lua new file mode 100644 index 0000000..e3c3c6c --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/surround.lua @@ -0,0 +1,6 @@ +return { +  "kylechui/nvim-surround", +  event = { "BufReadPre", "BufNewFile" }, +  version = "*", +  config = true, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/telescope.lua b/nvim/.config/nvim/lua/custom/plugins/telescope.lua new file mode 100644 index 0000000..19790dd --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/telescope.lua @@ -0,0 +1,16 @@ +return { +  "nvim-telescope/telescope.nvim", +  event = "VimEnter", +  branch = "0.1.x", +  dependencies = { +    "nvim-lua/plenary.nvim", +    { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, +    { "nvim-telescope/telescope-smart-history.nvim" }, +    { "nvim-telescope/telescope-ui-select.nvim" }, +    { "nvim-tree/nvim-web-devicons" }, +    "rest-nvim/rest.nvim", +  }, +  config = function() +    require "custom.telescope" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/textcase.lua b/nvim/.config/nvim/lua/custom/plugins/textcase.lua new file mode 100644 index 0000000..e335b38 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/textcase.lua @@ -0,0 +1,6 @@ +return { +  "johmsalas/text-case.nvim", +  dependencies = { "nvim-telescope/telescope.nvim" }, +  config = true, +  lazy = false, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/themes.lua b/nvim/.config/nvim/lua/custom/plugins/themes.lua new file mode 100644 index 0000000..0f9ca03 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/themes.lua @@ -0,0 +1,7 @@ +return { +  { "ellisonleao/gruvbox.nvim", priority = 1000, config = function() +    require("gruvbox").setup({}) +    vim.cmd([[colorscheme gruvbox]]) +    end +  }, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/todo-comments.lua b/nvim/.config/nvim/lua/custom/plugins/todo-comments.lua new file mode 100644 index 0000000..4b46f89 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/todo-comments.lua @@ -0,0 +1,6 @@ +return { +  "folke/todo-comments.nvim", +  event = "VimEnter", +  dependencies = { "nvim-lua/plenary.nvim" }, +  opts = { signs = false }, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/toggleterm.lua b/nvim/.config/nvim/lua/custom/plugins/toggleterm.lua new file mode 100644 index 0000000..8775389 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/toggleterm.lua @@ -0,0 +1,7 @@ +return { +  "akinsho/toggleterm.nvim", +  version = "*", +  config = function() +    require "custom.toggleterm" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/treesitter.lua b/nvim/.config/nvim/lua/custom/plugins/treesitter.lua new file mode 100644 index 0000000..dd37a3a --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/treesitter.lua @@ -0,0 +1,7 @@ +return { +  "nvim-treesitter/nvim-treesitter", +  build = ":TSUpdate", +  config = function() +    require "custom.treesitter" +  end, +} diff --git a/nvim/.config/nvim/lua/custom/plugins/vim-sleuth.lua b/nvim/.config/nvim/lua/custom/plugins/vim-sleuth.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/vim-sleuth.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/.config/nvim/lua/custom/plugins/which-key.lua b/nvim/.config/nvim/lua/custom/plugins/which-key.lua new file mode 100644 index 0000000..8ac7387 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/plugins/which-key.lua @@ -0,0 +1,15 @@ +return { +  "folke/which-key.nvim", +  event = "VimEnter", +  config = function() +    --TODO: move this to files where it is declared +    require("which-key").register { +      ["<leader>f"] = { name = "Find", _ = "which_key_ignore" }, +      ["<leader>T"] = { name = "Toggle options", _ = "which_key_ignore" }, +      ["<leader>t"] = { name = "ToggleTerm", _ = "which_key_ignore" }, +      ["<leader>g"] = { name = "Git", _ = "which_key_ignore" }, +      ["<leader>l"] = { name = "LSP", _ = "which_key_ignore" }, +      ["<leader><tab>"] = { name = "Tab pages", _ = "which_key_ignore" }, +    } +  end, +} diff --git a/nvim/.config/nvim/lua/custom/rest.lua b/nvim/.config/nvim/lua/custom/rest.lua new file mode 100644 index 0000000..b058279 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/rest.lua @@ -0,0 +1,14 @@ +require("rest-nvim").setup { +  keybinds = { +    { +      "<leader>rr", +      "<cmd>Rest run<cr>", +      "Run requesti under the cursor", +    }, +    { +      "<leader>rl", +      "<cmd>Rest run last<cr>", +      "Re-run latest request", +    }, +  }, +} diff --git a/nvim/.config/nvim/lua/custom/substitude.lua b/nvim/.config/nvim/lua/custom/substitude.lua new file mode 100644 index 0000000..e666195 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/substitude.lua @@ -0,0 +1,6 @@ +require("substitute").setup {} + +vim.keymap.set("n", ",", require("substitute").operator, { noremap = true }) +vim.keymap.set("n", ",,", require("substitute").line, { noremap = true }) +-- vim.keymap.set("n", "", require("substitute").eol, { noremap = true }) +vim.keymap.set("x", ",", require("substitute").visual, { noremap = true }) diff --git a/nvim/.config/nvim/lua/custom/telescope.lua b/nvim/.config/nvim/lua/custom/telescope.lua new file mode 100644 index 0000000..ffe6ac0 --- /dev/null +++ b/nvim/.config/nvim/lua/custom/telescope.lua @@ -0,0 +1,41 @@ +-- local data = assert(vim.fn.stdpath "data") --[[@as string]] + +require("telescope").setup { +  extensions = { +    fzf = {}, +    wrap_results = true, +    history = { +      -- path = vim.fs.joinpath(data, "telescope_history.sqlite3"), +      limit = 100, +    }, +    ["ui-select"] = { +      require("telescope.themes").get_dropdown(), +    }, +  }, +} + +pcall(require("telescope").load_extension, "fzf") +pcall(require("telescope").load_extension, "smart_history") +pcall(require("telescope").load_extension, "rest") +pcall(require("telescope").load_extension, "ui-select") + +local builtin = require "telescope.builtin" + +vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Search [H]elp" }) +vim.keymap.set("n", "<leader>fk", builtin.keymaps, { desc = "Search [K]eymaps" }) +vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Search [F]iles" }) +vim.keymap.set("n", "<leader>fs", builtin.builtin, { desc = "Search [S]elect Telescope" }) +vim.keymap.set("n", "<leader>fw", builtin.grep_string, { desc = "Search current [W]ord" }) +vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Search by [G]rep" }) +vim.keymap.set("n", "<leader>fd", builtin.diagnostics, { desc = "Search [D]iagnostics" }) +vim.keymap.set("n", "<leader>fr", builtin.resume, { desc = "Search [R]esume" }) +vim.keymap.set("n", "<leader>f.", builtin.oldfiles, { desc = 'Search Recent Files ("." for repeat)' }) +vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "[ ] Find existing buffers" }) +vim.keymap.set("n", "<leader>fn", function() +  require("telescope.builtin").find_files { cwd = vim.fn.stdpath "config" } +end, { desc = "Search [N]eovim files" }) + +vim.keymap.set("n", "<leader>fa", function() +  ---@diagnostic disable-next-line: param-type-mismatch +  builtin.find_files { cwd = vim.fs.joinpath(vim.fn.stdpath "data", "lazy") } +end) diff --git a/nvim/.config/nvim/lua/custom/toggleterm.lua b/nvim/.config/nvim/lua/custom/toggleterm.lua new file mode 100644 index 0000000..6aafb2f --- /dev/null +++ b/nvim/.config/nvim/lua/custom/toggleterm.lua @@ -0,0 +1,41 @@ +require("toggleterm").setup { +  size = function(term) +    if term.direction == "horizontal" then +      return 15 +    elseif term.direction == "vertical" then +      return vim.o.columns * 0.33 +    end +  end, +} + +local Terminal = require("toggleterm.terminal").Terminal +local on_open = function(_) +  vim.cmd "startinsert!" +  -- vim.keymap.set("n", "q", "<cmd>close<CR>", { noremap = true, silent = true, buffer = term.bufnr }) +end +local on_close = function(_) +  vim.cmd "startinsert!" +end +if vim.fn.executable "lazygit" then +  local lazygit = Terminal:new { +    cmd = "lazygit", +    dir = "git_dir", +    direction = "float", +    on_open = on_open, +    on_close = on_close, +    count = 999, +  } +  vim.keymap.set("n", "<leader>gg", function() +    lazygit:toggle() +  end, { desc = "ToggleTerm LazyGit" }) +end + +vim.keymap.set("n", "<leader>tf", function() +  Terminal:new({ count = vim.v.count1, on_open = on_open, on_close = on_close }):toggle(nil, "float") +end) +vim.keymap.set("n", "<leader>tv", function() +  Terminal:new({ count = vim.v.count1, on_open = on_open, on_close = on_close }):toggle(nil, "vertical") +end) +vim.keymap.set("n", "<leader>th", function() +  Terminal:new({ count = vim.v.count1, on_open = on_open, on_close = on_close }):toggle(nil, "horizontal") +end) diff --git a/nvim/.config/nvim/lua/custom/treesitter.lua b/nvim/.config/nvim/lua/custom/treesitter.lua new file mode 100644 index 0000000..5f8e8fb --- /dev/null +++ b/nvim/.config/nvim/lua/custom/treesitter.lua @@ -0,0 +1,51 @@ +local M = {} + +M.setup = function() +  local group = vim.api.nvim_create_augroup("custom-treesitter", { clear = true }) + +  require("nvim-treesitter.configs").setup { +    ensure_installed = { +      "bash", +      "c", +      "diff", +      "html", +      "lua", +      "luadoc", +      "json", +      "markdown", +      "vim", +      "vimdoc", +      "cpp", +      "cmake", +      "query", +      "http", +      "proto", +      "xml", +      "graphql", +    }, +    highlight = { enable = true }, +    indent = { enable = true }, +  } + +  local syntax_on = { +    -- elixir = true, +    -- php = true, +  } + +  vim.api.nvim_create_autocmd("FileType", { +    group = group, +    callback = function(args) +      local bufnr = args.buf +      local ft = vim.bo[bufnr].filetype +      pcall(vim.treesitter.start) + +      -- if syntax_on[ft] then +      --   vim.bo[bufnr].syntax = "on" +      -- end +    end, +  }) +end + +M.setup() + +return M diff --git a/nvim/.config/nvim/plugin/autocmds.lua b/nvim/.config/nvim/plugin/autocmds.lua new file mode 100644 index 0000000..6349fb8 --- /dev/null +++ b/nvim/.config/nvim/plugin/autocmds.lua @@ -0,0 +1,51 @@ +local aucmd = vim.api.nvim_create_autocmd +local function augroup(name) +  return vim.api.nvim_create_augroup("chell_" .. name, {}) +end + +-- highlight after yank +aucmd("TextYankPost", { +  desc = "Highlight when yanking (copying) text", +  group = augroup "highlight_yank", +  callback = function() +    vim.highlight.on_yank() +  end, +}) + +-- resize splits if window got resized +aucmd({ "VimResized" }, { +  group = augroup "resize_splits", +  callback = function() +    local current_tab = vim.fn.tabpagenr() +    vim.cmd "tabdo wincmd =" +    vim.cmd("tabnext " .. current_tab) +  end, +}) + +-- Auto create dir when saving a file, in case some intermediate directory does not exist +aucmd({ "BufWritePre" }, { +  group = augroup "auto_create_dir", +  callback = function(event) +    if event.match:match "^%w%w+:[\\/][\\/]" then +      return +    end +    local file = vim.uv.fs_realpath(event.match) or event.match +    vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") +  end, +}) + +-- Show cursor line only in active window +vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, { +  group = augroup "auto_cursorline_show", +  callback = function(event) +    if vim.bo[event.buf].buftype == "" then +      vim.opt_local.cursorline = true +    end +  end, +}) +vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, { +  group = augroup "auto_cursorline_hide", +  callback = function() +    vim.opt_local.cursorline = false +  end, +}) diff --git a/nvim/.config/nvim/plugin/keymaps.lua b/nvim/.config/nvim/plugin/keymaps.lua new file mode 100644 index 0000000..8e24efb --- /dev/null +++ b/nvim/.config/nvim/plugin/keymaps.lua @@ -0,0 +1,57 @@ +local set = vim.keymap.set + +set("n", "<leader>w", "<cmd>w<cr>", { desc = "Write buffer" }) + +set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" }) + +-- ui navigation +set("n", "<m-j>", "<c-w><c-j>") +set("n", "<m-k>", "<c-w><c-k>") +set("n", "<m-l>", "<c-w><c-l>") +set("n", "<m-h>", "<c-w><c-h>") + +set("n", "<m-<>", "<c-w>5<") +set("n", "<m->>", "<c-w>5>") +set("n", "<m-+>", "<c-w>4+") +set("n", "<m-->", "<c-w>4-") + +set("n", "<m-v>", "<cmd>vsplit<cr>") +set("n", "<m-s>", "<cmd>split<cr>") + +set("n", "<m-q>", "<cmd>q<cr>", { desc = "Quit window" }) + +set("n", "<m-t>", "<cmd>tabnew<cr>", { desc = "New Tab" }) +set("n", "<s-m-t>", "<cmd>tabclose<cr>", { desc = "Close Tab" }) +set("n", "<m-n>", "<cmd>tabnext<cr>", { desc = "Next Tab" }) +set("n", "<m-p>", "<cmd>tabprevious<cr>", { desc = "Previous Tab" }) + +-- Toggle hlsearch if it's on, otherwise just do "enter" +set("n", "<cr>", function() +  ---@diagnostic disable-next-line: undefined-field +  if vim.opt.hlsearch:get() then +    vim.cmd.nohl() +    return "" +  else +    return "<cr>" +  end +end, { expr = true }) + +-- useful for indent text +set("v", ">", ">gv") +set("v", "<", "<gv") + +--swap lines +set("n", "<c-j>", function() +  if vim.opt.diff:get() then +    vim.cmd [[normal! ]c]] +  else +    vim.cmd [[m .+1<CR>==]] +  end +end) +set("n", "<c-k>", function() +  if vim.opt.diff:get() then +    vim.cmd [[normal! [c]] +  else +    vim.cmd [[m .-2<cr>==]] +  end +end) diff --git a/nvim/.config/nvim/plugin/netrw.lua b/nvim/.config/nvim/plugin/netrw.lua new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nvim/.config/nvim/plugin/netrw.lua diff --git a/nvim/.config/nvim/plugin/options.lua b/nvim/.config/nvim/plugin/options.lua new file mode 100644 index 0000000..cc3016c --- /dev/null +++ b/nvim/.config/nvim/plugin/options.lua @@ -0,0 +1,41 @@ +local opt = vim.opt + +opt.number = true +opt.relativenumber = true + +opt.mouse = "a" + +opt.clipboard = "unnamedplus" -- Sync clipboard between OS and Neovim. + +opt.breakindent = true -- Enable break indent + +opt.undofile = true -- Save undo history + +opt.ignorecase = true -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +opt.smartcase = true + +opt.signcolumn = "yes" -- Keep signcolumn on by default + +opt.updatetime = 250 -- Decrease update time + +opt.timeoutlen = 300 -- Decrease mapped sequence wait time + +opt.splitright = true -- Configure how new splits should be opened +opt.splitbelow = true + +opt.list = true -- Sets how neovim will display certain whitespace characters in the editor. +opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" } + +-- opt.inccommand = "split" -- Preview substitutions live + +opt.cursorline = true -- Show which line your cursor is on + +opt.scrolloff = 10 -- Minimal number of screen lines to keep above and below the cursor. +opt.sidescrolloff = 5 + +opt.hlsearch = true -- Set highlight on search +opt.incsearch = true + +opt.background = "dark" + +opt.laststatus = 3 diff --git a/nvim/.config/nvim/plugin/terminal.lua b/nvim/.config/nvim/plugin/terminal.lua new file mode 100644 index 0000000..0249feb --- /dev/null +++ b/nvim/.config/nvim/plugin/terminal.lua @@ -0,0 +1,14 @@ +local opt = vim.opt_local + +-- Set local settings for terminal buffers +vim.api.nvim_create_autocmd("TermOpen", { +  group = vim.api.nvim_create_augroup("custom-term-open", {}), +  callback = function() +    opt.number = false +    opt.relativenumber = false +    opt.scrolloff = 0 +  end, +}) + +-- Easily hit escape in terminal mode. +vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>") diff --git a/nvim/.config/nvim/stylua.toml b/nvim/.config/nvim/stylua.toml new file mode 100644 index 0000000..364ef9c --- /dev/null +++ b/nvim/.config/nvim/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +no_call_parentheses = true | 
