diff --git a/.github/README.md b/.github/README.md index 23b6033..6d5c4cb 100755 --- a/.github/README.md +++ b/.github/README.md @@ -44,31 +44,6 @@ Below is a representation of the structure of the configuration in tree format: ├──  lazy-lock.json ├──  LICENSE ├──  lua -│ ├──  config -│ │ ├──  cmp -│ │ │ └──  dict.lua -│ │ ├──  compile.lua -│ │ ├──  dashboard.lua -│ │ ├──  hydra -│ │ │ ├──  hydra.lua -│ │ │ ├──  spelling.lua -│ │ │ ├──  telescope.lua -│ │ │ └──  windows.lua -│ │ ├──  lsp -│ │ │ ├──  diagnostics.lua -│ │ │ ├──  gitsigns.lua -│ │ │ ├──  keymaps.lua -│ │ │ └──  navic.lua -│ │ ├──  lualine -│ │ │ ├──  components.lua -│ │ │ ├──  config.lua -│ │ │ ├──  highlights.lua -│ │ │ └──  init.lua -│ │ └──  neo-tree -│ │ ├──  init.lua -│ │ └──  sources -│ │ └──  filesystem -│ │ └──  components.lua │ ├──  core │ │ ├──  autocmds.lua │ │ ├──  icons.lua @@ -76,86 +51,33 @@ Below is a representation of the structure of the configuration in tree format: │ │ ├──  lazy.lua │ │ ├──  logo.lua │ │ └──  options.lua -│ ├──  resources -│ │ ├──  coding.lua -│ │ ├──  colorscheme.lua -│ │ ├──  editor.lua -│ │ ├──  formatting.lua -│ │ ├──  lang -│ │ │ ├──  clangd.lua -│ │ │ ├──  docker.lua -│ │ │ ├──  java.lua -│ │ │ ├──  json.lua -│ │ │ ├──  markdown.lua -│ │ │ ├──  nix.lua -│ │ │ ├──  php.lua -│ │ │ ├──  python.lua -│ │ │ ├──  rust.lua -│ │ │ └──  typescript.lua -│ │ ├──  lsp.lua -│ │ ├──  settings.lua -│ │ ├──  tools.lua -│ │ ├──  treesitter.lua -│ │ ├──  ui.lua -│ │ └──  util.lua -│ └──  util.lua -├──  README.md -> .github/README.md -├──  snippets -│ ├──  all.lua -│ ├──  java.snippets -│ ├──  markdown.lua -│ ├──  package.json -│ ├──  vscode -│ │ ├──  c.json -│ │ ├──  cpp.json -│ │ ├──  css.json -│ │ ├──  fennel.json -│ │ ├──  frameworks -│ │ │ ├──  ejs.json -│ │ │ ├──  flutter.json -│ │ │ ├──  jekyll.json├──  cheatsheet.txt -├──  doc -│ └──  nvim-forge.txt -├──  Dockerfile -├──  init.lua -├──  lazy-lock.json -├──  LICENSE -├──  lua -│ ├──  config -│ │ ├──  cmp -│ │ │ └──  dict.lua -│ │ ├──  compile.lua -│ │ ├──  dashboard.lua -│ │ ├──  hydra -│ │ │ ├──  hydra.lua -│ │ │ ├──  spelling.lua -│ │ │ ├──  telescope.lua -│ │ │ └──  windows.lua -│ │ ├──  lsp -│ │ │ ├──  diagnostics.lua -│ │ │ ├──  gitsigns.lua -│ │ │ ├──  keymaps.lua -│ │ │ └──  navic.lua -│ │ ├──  lualine -│ │ │ ├──  components.lua -│ │ │ ├──  config.lua -│ │ │ ├──  highlights.lua -│ │ │ └──  init.lua -│ │ └──  neo-tree -│ │ ├──  init.lua -│ │ └──  sources -│ │ └──  filesystem -│ │ └──  components.lua -│ ├──  core -│ │ ├──  autocmds.lua -│ │ ├──  icons.lua -│ │ ├──  keymaps.lua -│ │ ├──  lazy.lua -│ │ ├──  logo.lua -│ │ └──  options.lua -│ ├──  resources +│ ├──  plugins │ │ ├──  coding.lua │ │ ├──  colorscheme.lua +│ │ ├──  config +│ │ │ ├──  cmp +│ │ │ │ └──  dict.lua +│ │ │ ├──  compile.lua +│ │ │ ├──  dashboard.lua +│ │ │ ├──  hydra +│ │ │ │ ├──  hydra.lua +│ │ │ │ ├──  spelling.lua +│ │ │ │ ├──  telescope.lua +│ │ │ │ └──  windows.lua +│ │ │ ├──  lsp +│ │ │ │ ├──  diagnostics.lua +│ │ │ │ ├──  gitsigns.lua +│ │ │ │ └──  keymaps.lua +│ │ │ ├──  lualine +│ │ │ │ ├──  components.lua +│ │ │ │ ├──  config.lua +│ │ │ │ ├──  highlights.lua +│ │ │ │ └──  init.lua +│ │ │ └──  neo-tree +│ │ │ ├──  init.lua +│ │ │ └──  sources +│ │ │ └──  filesystem +│ │ │ └──  components.lua │ │ ├──  editor.lua │ │ ├──  formatting.lua │ │ ├──  lang @@ -176,6 +98,7 @@ Below is a representation of the structure of the configuration in tree format: │ │ ├──  ui.lua │ │ └──  util.lua │ └──  util.lua +├──  neovim ├──  README.md -> .github/README.md ├──  snippets │ ├──  all.lua @@ -242,59 +165,8 @@ Below is a representation of the structure of the configuration in tree format: │ ├──  hi.dict │ └──  README.md └──  stylua.toml -│ │ │ └──  vue -│ │ │ ├──  html.json -│ │ │ ├──  javascript.json -│ │ │ ├──  pug.json -│ │ │ └──  vue.json -│ │ ├──  gdscript.json -│ │ ├──  gitcommit.json -│ │ ├──  global.json -│ │ ├──  glsl.json -│ │ ├──  go.json -│ │ ├──  haskell.json -│ │ ├──  html.json -│ │ ├──  java.json -│ │ ├──  javascript -│ │ │ ├──  javascript.json -│ │ │ ├──  react-native-ts.json -│ │ │ ├──  react-native.json -│ │ │ ├──  react-ts.json -│ │ │ ├──  react.json -│ │ │ └──  typescript.json -│ │ ├──  kotlin.json -│ │ ├──  kubernetes.json -│ │ ├──  latex -│ │ │ ├──  latex-snippets.json -│ │ │ └──  vscode-latex-snippets.json -│ │ ├──  latex.json -│ │ ├──  lua.json -│ │ ├──  markdown.json -│ │ ├──  meson.json -│ │ ├──  norg.json -│ │ ├──  org.json -│ │ ├──  package.json -│ │ ├──  python -│ │ │ ├──  base.json -│ │ │ ├──  comprehension.json -│ │ │ ├──  debug.json -│ │ │ ├──  python.json -│ │ │ └──  unittest.json -│ │ ├──  rust.json -│ │ ├──  scala.json -│ │ ├──  shell.json -│ │ └──  sql.json -│ └──  yaml.lua -├──  spell -│ ├──  en.dict -│ ├──  en.utf-8.add -│ ├──  en.utf-8.add.spl -│ ├──  es.dict -│ ├──  hi.dict -│ └──  README.md -└──  stylua.toml ``` -The `lua/` subdirectory is where the majority of the configuration resides, with the `core/` subdirectory containing the core configuration, `config/` containing the configuration for plugins when a more substantial configuration is necessary for a plugin and `resources/` containing the enumeration of and initial setup configurations for the various plugins used by the configuration and managed by `lazy.nvim`. Within the `resources/` subdirectory is an additional `lang/` subdirectory that contains the configuration for language servers and other language-specific configuration. +The `lua/` subdirectory is where the majority of the configuration resides, with the `core/` subdirectory containing the core configuration, `plugins/config/` containing the configuration for plugins when a more substantial configuration is necessary for a plugin and `plugins/` containing the enumeration of and initial setup configurations for the various plugins used by the configuration. All of which is, of course, managed by `lazy.nvim`. Within the `resources/` subdirectory is an additional `lang/` subdirectory that contains the configuration for language servers and other language-specific configuration. ## Inspiration diff --git a/cheatsheet.txt b/cheatsheet.txt index 42853a0..92ec4f0 100755 --- a/cheatsheet.txt +++ b/cheatsheet.txt @@ -127,3 +127,11 @@ LSP | l FOLD | f GOTO | g SEARCH | s + +ADD SURROUNDING MARKERS | Ga +REMOVE SURROUNDING MARKERS | Gd +Find surrounding (to the right) | Gf +Find surrounding (to the left) | GF +Highlight surrounding | Gh +Replace surrounding | Gr +Update `n_lines` | Gn diff --git a/doc/nvim-forge.txt b/doc/nvim-forge.txt index 32fe228..c6bc0c0 100755 --- a/doc/nvim-forge.txt +++ b/doc/nvim-forge.txt @@ -14,7 +14,7 @@ Table of Contents *nvim-forge-table-of-contents* My Winchester Mystery NeoVim Configuration, using `lazy.nvim` for plugin management and Lua as its configuration language. My _Personal Development Environment_ (PDE) and the -core tool used in cultivating my Personal Knowledge Base (PKB). +nvim-forge.core tool used in cultivating my Personal Knowledge Base (PKB). **Warning** This is my personal configuration, subject to experimentation and @@ -98,7 +98,7 @@ Below is a representation of the structure of the configuration in tree format: │ │ └──  sources │ │ └──  filesystem │ │ └──  components.lua - │ ├──  core + │ ├──  nvim-forge.core │ │ ├──  autocmds.lua │ │ ├──  icons.lua │ │ ├──  keymaps.lua @@ -175,7 +175,7 @@ Below is a representation of the structure of the configuration in tree format: │ │ └──  sources │ │ └──  filesystem │ │ └──  components.lua - │ ├──  core + │ ├──  nvim-forge.core │ │ ├──  autocmds.lua │ │ ├──  icons.lua │ │ ├──  keymaps.lua @@ -325,10 +325,10 @@ Below is a representation of the structure of the configuration in tree format: < The `lua/` subdirectory is where the majority of the configuration resides, -with the `core/` subdirectory containing the core configuration, `config/` -containing the configuration for plugins when a more substantial configuration +with the `nvim-forge.core/` subdirectory containing the nvim-forge.core configuration, `config/` +containing the configuration for nvim-forge.plugins when a more substantial configuration is necessary for a plugin and `resources/` containing the enumeration of and -initial setup configurations for the various plugins used by the configuration +initial setup configurations for the various nvim-forge.plugins used by the configuration and managed by `lazy.nvim`. Within the `resources/` subdirectory is an additional `lang/` subdirectory that contains the configuration for language servers and other language-specific configuration. diff --git a/init.lua b/init.lua index 3032efb..0818055 100755 --- a/init.lua +++ b/init.lua @@ -1,3 +1 @@ ----@diagnostic disable-next-line: different-requires -require("core.lazy") - +require("init").bootstrap() diff --git a/lazy-lock.json b/lazy-lock.json index 039a451..ebfe031 100755 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,102 +1,77 @@ { + "ChatGPT.nvim": { "branch": "main", "commit": "df53728e05129278d6ea26271ec086aa013bed90" }, "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, "SchemaStore.nvim": { "branch": "main", "commit": "4ce271f0db8b5224b4d69a43a75c13f5b4dcba43" }, "animation.nvim": { "branch": "main", "commit": "fb77091ab72ec9971aee0562e7081182527aaa6a" }, "barbecue.nvim": { "branch": "main", "commit": "d38a2a023dfb1073dd0e8fee0c9be08855d3688f" }, "bufferline.nvim": { "branch": "main", "commit": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef" }, - "cheatsheet.nvim": { "branch": "master", "commit": "9716f9aaa94dd1fd6ce59b5aae0e5f25e2a463ef" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-calc": { "branch": "main", "commit": "ce91d14d2e7a8b3f6ad86d85e34d41c1ae6268d9" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-cmdline-history": { "branch": "master", "commit": "003573b72d4635ce636234a826fa8c4ba2895ffe" }, - "cmp-conventionalcommits": { "branch": "master", "commit": "a4dfacf0601130b7f8afa7c948d735c27802fb7f" }, - "cmp-git": { "branch": "main", "commit": "8d8993680d627c8f13bd85094eba84604107dbdd" }, "cmp-luasnip-choice": { "branch": "master", "commit": "97a367851bc17984b56164b5427a53919aed873a" }, - "cmp-npm": { "branch": "main", "commit": "2337f109f51a09297596dd6b538b70ccba92b4e4" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, - "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f0f53f704c08ea501f9d222b23491b0d354644b0" }, - "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp-treesitter": { "branch": "master", "commit": "13e4ef8f4dd5639fca2eb9150e68f47639a9b37d" }, - "cmp-zsh": { "branch": "main", "commit": "c24db8e58fac9006ec23d93f236749288d00dec9" }, - "cmp_kitty": { "branch": "main", "commit": "a0716db2efb4c452600ef1e4a3ca610889279118" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "codeium.nvim": { "branch": "main", "commit": "a070f57c0f54bd940436b94c8b679bcad5a48811" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, - "compile-nvim": { "branch": "main", "commit": "f7ad312ec5d0ae4a0554a7e52349ee371b868a5d" }, "conform.nvim": { "branch": "master", "commit": "9d5ba06d6ee7418c674f498634617416d15b6239" }, "copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" }, "copilot.lua": { "branch": "master", "commit": "f7612f5af4a7d7615babf43ab1e67a2d790c13a6" }, - "crates.nvim": { "branch": "main", "commit": "b4f4987ccdb1cc3899ee541ef4375c73c48c4570" }, "dashboard-nvim": { "branch": "master", "commit": "39f308a0b845b8da46f83c8a2d69f0191d4b7a8f" }, "dressing.nvim": { "branch": "master", "commit": "18e5beb3845f085b6a33c24112b37988f3f93c06" }, "emmet-vim": { "branch": "master", "commit": "def5d57a1ae5afb1b96ebe83c4652d1c03640f4d" }, + "flutter-tools.nvim": { "branch": "main", "commit": "ac52972c4a6addbfec7946d38c67d2558af8bca6" }, "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, "garbage-day.nvim": { "branch": "main", "commit": "3af496f0d1dc6586dcf4ceda6bbf61a8f820ab66" }, "gitsigns.nvim": { "branch": "main", "commit": "70584ff9aae8078b64430c574079d79620b8f06d" }, "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, - "hydra.nvim": { "branch": "master", "commit": "3ced42c0b6a6c85583ff0f221635a7f4c1ab0dd0" }, "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, - "keymap-layer.nvim": { "branch": "master", "commit": "e46840f9f377766e856964a49d7f351de3188a38" }, "kiwi.nvim": { "branch": "master", "commit": "1a625771e3d3d9f50ca28a4501c11842f6c1ec1e" }, - "lazy.nvim": { "branch": "main", "commit": "31ddbea7c10b6920c9077b66c97951ca8682d5c8" }, - "lazygit.nvim": { "branch": "main", "commit": "0ada6c6e7e138df92f5009b6952f4ac41248305a" }, + "lazy.nvim": { "branch": "main", "commit": "bef521ac89c8d423f9d092e37b58e8af0c099309" }, "llm.nvim": { "branch": "main", "commit": "51b76dac9c33c0122adfe28daf52ceaa31c4aa02" }, "lsp_signature.nvim": { "branch": "master", "commit": "c6aeb2f1d2538bbdfdaab1664d9d4c3c75aa9db8" }, - "lspkind-nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, - "lspsaga.nvim": { "branch": "main", "commit": "d5aa1a02a23b5725054928426b1de6932a6d3bc3" }, "lualine.nvim": { "branch": "master", "commit": "b5e8bb642138f787a2c1c5aedc2a78cb2cebbd67" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9dfcf2036c223920826140f0151d929a43f9eceb" }, "mason-null-ls.nvim": { "branch": "main", "commit": "e270134d83ba59425edc53356c6fd337b61bb8dd" }, "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, "middleclass": { "branch": "master", "commit": "9fab4d5bca67262614960960ca35c4740eb2be2c" }, "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, - "mini.indentscope": { "branch": "main", "commit": "cf07f19e718ebb0bcc5b00999083ce11c37b8d40" }, + "mini.hipatterns": { "branch": "main", "commit": "0a72439dbded766af753a3e7ec0a5b21d0f8ada0" }, "mini.pairs": { "branch": "main", "commit": "04f58f2545ed80ac3b52dd4826e93f33e15b2af6" }, - "mini.surround": { "branch": "main", "commit": "49e0364b8c9a3258b485c5ece40bb0f3a5e94b1c" }, "monokai-pro.nvim": { "branch": "master", "commit": "1b9b086df95ad9a6b946c56f65fa2d048297c00b" }, "neo-tree-diagnostics.nvim": { "branch": "main", "commit": "e00434c3cf8637bcaf70f65c2b9d82b0cc9bd7dc" }, "neo-tree.nvim": { "branch": "main", "commit": "16d1b194376bf1fc2acd89ccb3c29ba8315bfcea" }, - "neodev.nvim": { "branch": "main", "commit": "ce9a2e8eaba5649b553529c5498acb43a6c317cd" }, "nix-develop.nvim": { "branch": "main", "commit": "afea026f5c478c000a8af8de87f7b711676387ab" }, "noice.nvim": { "branch": "main", "commit": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12" }, "none-ls.nvim": { "branch": "main", "commit": "18910d09d21d7df339805343bfe4a2b2e41c057b" }, "nui.nvim": { "branch": "main", "commit": "cbd2668414331c10039278f558630ed19b93e69b" }, "nvim-cmp": { "branch": "main", "commit": "97dc716fc914c46577a4f254035ebef1aa72558a" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, "nvim-dap": { "branch": "master", "commit": "405df1dcc2e395ab5173a9c3d00e03942c023074" }, "nvim-dap-python": { "branch": "master", "commit": "66560f0ebddf96604f7037e1efad3ba6942761e6" }, "nvim-jdtls": { "branch": "master", "commit": "8eb5f0dbe6e126b392ddcaf45893358619893e45" }, + "nvim-lightbulb": { "branch": "master", "commit": "02aacd93b9b2367e6dbdd20f43b525f701faf834" }, + "nvim-lint": { "branch": "master", "commit": "6670b3ac73fa4caf720f017b91c619e9424d955e" }, "nvim-lspconfig": { "branch": "master", "commit": "6e5c78ebc9936ca74add66bda22c566f951b6ee5" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, "nvim-scrollbar": { "branch": "main", "commit": "35f99d559041c7c0eff3a41f9093581ceea534e8" }, - "nvim-spectre": { "branch": "master", "commit": "2b012554a2536465243c0dff3605b5927c49ed23" }, "nvim-treesitter": { "branch": "master", "commit": "c65413f2ac20d1d4b91fe4eb32d9d25525b34b83" }, "nvim-treesitter-context": { "branch": "master", "commit": "f19766163c18515fb4d3c12d572bf9cba6cdb990" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "d2a4ffc22d9d38d44edb73da007b3cf43451e9b4" }, "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "734ebad31c81c6198dfe102aa23280937c937c42" }, "nvim-web-devicons": { "branch": "master", "commit": "3ee60deaa539360518eaab93a6c701fe9f4d82ef" }, - "nvim-window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, "plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" }, - "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "quicknote.nvim": { "branch": "master", "commit": "2fc56f96ef1d983609c1c40b799d7ec32693362a" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "580bc045c7ab3ab3ebd267774038c0d8cc19c789" }, "rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, - "sort.nvim": { "branch": "main", "commit": "c789da6968337d2a61104a929880b5f144e02855" }, - "statuscol.nvim": { "branch": "main", "commit": "d954893262a57a92e46edd87de67e2b3fe72305e" }, "swenv.nvim": { "branch": "main", "commit": "c11eeaa6f8f05abdcbb0a53d0ac290e3f9fabd2c" }, "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, - "todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" }, "toggleterm.nvim": { "branch": "main", "commit": "193786e0371e3286d3bc9aa0079da1cd41beaa62" }, "trouble.nvim": { "branch": "main", "commit": "b9cf677f20bb2faa2dacfa870b084e568dca9572" }, "venv-selector.nvim": { "branch": "main", "commit": "3c57922256e7e26205a25f5a42ecf7104d9f2c78" }, "vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" }, - "vim-eunuch": { "branch": "master", "commit": "8fb3904be27b6b60d086f87c2570085902414069" }, "vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" }, - "vim-startuptime": { "branch": "master", "commit": "ac2cccb5be617672add1f4f3c0a55ce99ba34e01" }, "vim-visual-multi": { "branch": "master", "commit": "fe1ec7e430013b83c8c2dee85ae496251b71e253" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, "windows.nvim": { "branch": "main", "commit": "c7492552b23d0ab30325e90b56066ec51242adc8" } diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua old mode 100755 new mode 100644 index 0ac2db1..d613453 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -1,4 +1,5 @@ -local Util = require("util") +local Utils = require("utils") + -- ───────────────────────────────────────────────────────────────── -- Turn off paste mode when leaving insert vim.api.nvim_create_autocmd("InsertLeave", { @@ -6,26 +7,28 @@ vim.api.nvim_create_autocmd("InsertLeave", { pattern = "*", }) --- +---------------------------------------------------------------+ +-- ───────────────────────────────────────────────────────────────── -- Highlight on yank vim.api.nvim_create_autocmd({ "TextYankPost" }, { - group = Util.augroup("highlight_yank"), + group = Utils.augroup("highlight_yank"), callback = function() - vim.highlight.on_yank({ higroup = "Search", timeout = 200 }) + vim.highlight.on_yank({ higroup = "Visual" }) end, }) --- +---------------------------------------------------------------+ + +-- ───────────────────────────────────────────────────────────────── -- resize splits if window got resized vim.api.nvim_create_autocmd({ "VimResized" }, { - group = Util.augroup("resize_splits"), + group = Utils.augroup("resize_splits"), callback = function() vim.cmd("tabdo wincmd =") end, }) --- +---------------------------------------------------------------+ + +-- ───────────────────────────────────────────────────────────────── -- close some filetypes with vim.api.nvim_create_autocmd("FileType", { - group = Util.augroup("close_with_q"), + group = Utils.augroup("close_with_q"), pattern = { "qf", "help", @@ -43,53 +46,29 @@ vim.api.nvim_create_autocmd("FileType", { end, }) --- Set wrap and spell in markdown and gitcommit --- vim.api.nvim_create_autocmd({ "FileType" }, { --- group = Util.augroup("wrap_spell"), --- pattern = { "gitcommit", "markdown" }, --- callback = function() --- -- vim.opt_local.wrap = true -- set globally, so I don't need this on to throw errors. I already got enough of that, thanks --- vim.opt_local.spell = true --- end, --- }) --- +---------------------------------------------------------------+ --- remember folds -vim.api.nvim_create_autocmd({ "BufWinLeave" }, { - pattern = "?*", - group = Util.augroup("remember_folds"), - callback = function() - vim.cmd([[silent! mkview 1]]) - end, -}) -vim.api.nvim_create_autocmd({ "BufWinEnter" }, { - pattern = "?*", - group = Util.augroup("remember_folds"), +-- ───────────────────────────────────────────────────────────────── +-- fix comment +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + group = Utils.augroup("comment_newline"), + pattern = { "*" }, callback = function() - vim.cmd([[silent! loadview 1]]) + vim.cmd([[set formatoptions-=cro]]) end, }) --- +---------------------------------------------------------------+ + +-- ───────────────────────────────────────────────────────────────── -- set shell for NixOS quirkiness vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "BufNewFile" }, { pattern = "*", - group = Util.augroup("set_shell"), + group = Utils.augroup("set_shell"), callback = function() vim.cmd([[set shell=/run/current-system/sw/bin/zsh]]) end, }) --- +---------------------------------------------------------------+ --- fix comment -vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "BufNewFile" }, { - group = Util.augroup("comment_newline"), - pattern = { "*" }, - callback = function() - vim.cmd([[set formatoptions-=cro]]) - end, -}) --- +---------------------------------------------------------------+ + +-- ───────────────────────────────────────────────────────────────── -- determine project root vim.api.nvim_create_autocmd({ "BufEnter" }, { - group = Util.augroup("project_root"), pattern = { "" }, callback = function() local get_project_dir = function() @@ -102,38 +81,44 @@ vim.api.nvim_create_autocmd({ "BufEnter" }, { vim.opt.titlestring = get_project_dir() end, }) --- +---------------------------------------------------------------+ + -- clear cmd output vim.api.nvim_create_autocmd({ "CursorHold" }, { - group = Util.augroup("clear_term"), + group = Utils.augroup("clear_term"), callback = function() vim.cmd([[echon '']]) end, }) --- +---------------------------------------------------------------+ --- placement of the help window + vim.api.nvim_create_autocmd({ "FileType" }, { - group = Util.augroup("help_placement"), pattern = { "help" }, callback = function() vim.cmd([[wincmd L]]) end, }) --- +---------------------------------------------------------------+ --- terminal settings + vim.api.nvim_create_autocmd({ "TermOpen" }, { - group = Util.augroup("terminal_settings"), pattern = { "*" }, callback = function() vim.opt_local["number"] = false vim.opt_local["signcolumn"] = "no" + vim.opt_local["foldcolumn"] = "0" end, }) --- +---------------------------------------------------------------+ +-- ───────────────────────────────────────────────────────────────── +-- fix comment on new line +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + pattern = { "*" }, + callback = function() + vim.cmd([[set formatoptions-=cro]]) + end, +}) + +-- ───────────────────────────────────────────────────────────────── -- Auto create dir when saving a file, in case some intermediate directory does not exist vim.api.nvim_create_autocmd({ "BufWritePre" }, { - group = Util.augroup("auto_create_dir"), + group = Utils.augroup("auto_create_dir"), callback = function(event) if event.match:match("^%w%w+://") then return @@ -143,29 +128,22 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { end, }) --- +---------------------------------------------------------------+ --- Update file when there are changes to it -vim.api.nvim_create_autocmd({ "FocusGained" }, { - group = Util.augroup("update_file_when_changed"), +-- ───────────────────────────────────────────────────────────────── +-- placement of the help window +vim.api.nvim_create_autocmd({ "FileType" }, { + group = Utils.augroup("help_placement"), + pattern = { "help" }, callback = function() - vim.cmd("checktime") + vim.cmd([[wincmd L]]) end, }) --- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ --- go to last loc when opening a buffer -vim.api.nvim_create_autocmd("BufReadPost", { - group = Util.augroup("last_loc"), - callback = function(event) - local exclude = { "gitcommit" } - local buf = event.buf - if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then - return - end - vim.b[buf].lazyvim_last_loc = true - local mark = vim.api.nvim_buf_get_mark(buf, '"') - local lcount = vim.api.nvim_buf_line_count(buf) - if mark[1] > 0 and mark[1] <= lcount then - pcall(vim.api.nvim_win_set_cursor, 0, mark) - end +-- +---------------------------------------------------------------+ +-- terminal settings +vim.api.nvim_create_autocmd({ "TermOpen" }, { + group = Utils.augroup("terminal_settings"), + pattern = { "*" }, + callback = function() + vim.opt_local["number"] = false + vim.opt_local["signcolumn"] = "no" end, }) diff --git a/lua/core/commands.lua b/lua/core/commands.lua new file mode 100644 index 0000000..59787ef --- /dev/null +++ b/lua/core/commands.lua @@ -0,0 +1,19 @@ +local Utils = require("utils") +local create_command = vim.api.nvim_create_user_command + +--- Toggle monochrome mode +create_command("MonochromeModeToggle", function() + local monochrome_element = "neo-tree" + local mnk_config = require("monokai-pro.config") + local mnk_opts = Utils.plugin.opts("monokai-pro.nvim") + local bg_clear_list = mnk_opts.background_clear or {} + local is_monochrome_mode = vim.tbl_contains(bg_clear_list, monochrome_element) + if is_monochrome_mode then + -- stylua: ignore + bg_clear_list = vim.tbl_filter(function(value) return value ~= monochrome_element end, bg_clear_list) + else + vim.list_extend(bg_clear_list, { monochrome_element }) + end + mnk_config.extend({ background_clear = bg_clear_list }) + vim.cmd([[colorscheme monokai-pro]]) +end, { nargs = 0 }) diff --git a/lua/core/icons.lua b/lua/core/icons.lua old mode 100755 new mode 100644 index 117437c..018217e --- a/lua/core/icons.lua +++ b/lua/core/icons.lua @@ -1,4 +1,29 @@ -return { +---@alias BorderStyle "rounded" | "double" | "thin" | "empty" | "thick" +---@alias BorderOrder "t-r-b-l-tl-tr-br-bl" | "tl-t-tr-r-br-b-bl-l" + +---@class BorderIcons +---@field top? string +---@field right? string +---@field bottom? string +---@field left? string +---@field top_left? string +---@field top_right? string +---@field bottom_right? string +---@field bottom_left? string + +---@class core.icons +local M = { + mason = { + pending = " ", + installed = "󰄳 ", + uninstalled = "󰚌 ", + }, + lazy = { + ft = "", + lazy = "󰂠 ", + loaded = " ", + not_loaded = " ", + }, diagnostics = { error = "", warn = "", @@ -18,12 +43,12 @@ return { deleted = "", }, gitsigns = { - add = "┃", - change = "┋", - delete = "", - topdelhfe = "", - changedelete = "┃", - untracked = "┃", + add = "│", + change = "┊", + delete = "󰍵", + topdelete = "‾", + changedelete = "~", + untracked = "│", }, kinds = { Array = "", @@ -63,8 +88,28 @@ return { Variable = "", Macro = "", -- Macro }, + ---@type table borders = { - --- @class BorderIcons + rounded = { + top = "─", + right = "│", + bottom = "─", + left = "│", + top_left = "╭", + top_right = "╮", + bottom_right = "╯", + bottom_left = "╰", + }, + double = { + top = "═", + right = "║", + bottom = "═", + left = "║", + top_left = "╔", + top_right = "╗", + bottom_right = "╝", + bottom_left = "╚", + }, thin = { top = "▔", right = "▕", @@ -75,7 +120,6 @@ return { bottom_right = "🭿", bottom_left = "🭼", }, - ---@type BorderIcons empty = { top = " ", right = " ", @@ -86,7 +130,6 @@ return { bottom_right = " ", bottom_left = " ", }, - ---@type BorderIcons thick = { top = "▄", right = "█", @@ -98,7 +141,17 @@ return { bottom_left = "▀", }, }, - misc = { + brain = { codeium = "󰘦 ", + copilot = " ", + }, +} + +M.colors = { + brain = { + codeium = "#09B6A2", + copilot = "#FEFFFF", }, } + +return M diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..0c1e23b --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,52 @@ +local Profile = require("profile") +local Utils = require("utils") + +---@class Core +---@field icons core.icons +---@field logos core.logos +local M = {} + +setmetatable(M, { + __index = function(_, k) + local mod = require("core." .. k) + return mod + end, +}) + +---@param mod "autocmds" | "options" | "keymaps" | "commands" +M.load = function(mod) + Utils.try(function() + require("core." .. mod) + end, { msg = "Error loading '" .. mod .. "'" }) +end + +M.setup = function() + local no_file = vim.fn.argc(-1) == 0 + -- Lazy load `autocmds` when opening a file + if not no_file then + M.load("autocmds") + M.load("commands") + end + + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + group = group, + callback = function() + if no_file then + M.load("autocmds") + M.load("commands") + end + M.load("keymaps") + end, + }) +end + +M.init = function() + M.load("options") + local colorscheme = vim.g.colors_name + if colorscheme == nil then + vim.cmd.colorscheme("torte") + end +end + +return M diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua old mode 100755 new mode 100644 index 736acf3..f211ff3 --- a/lua/core/keymaps.lua +++ b/lua/core/keymaps.lua @@ -1,171 +1,77 @@ -local opts = { noremap = true, silent = true } +local Utils = require("utils") --- Shorten function name -local map = vim.api.nvim_set_keymap +local map = Utils.safe_keymap_set --- Modes --- normal_mode = "n", --- insert_mode = "i", --- visual_mode = "v", --- visual_block_mode = "x", --- term_mode = "t", --- command_mode = "c", --- +---------------------------------------------------------------+ +-------------------- General Mappings -------------------------- +map("n", "w", "w!", { desc = "Save" }) +map("n", "q", "q!", { desc = "Quit" }) +map("n", "Q", "qa!", { desc = "Quit all" }) +map("n", "", "", { desc = "Switch buffer" }) --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Window Navigation ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ +-------------------- Better window navigation ------------------ +map("n", "", "h", { desc = "Go to left window", remap = true }) +map("n", "", "j", { desc = "Go to lower window", remap = true }) +map("n", "", "k", { desc = "Go to upper window", remap = true }) +map("n", "", "l", { desc = "Go to right window", remap = true }) -map("n", "", "h", opts) -map("n", "", "l", opts) -map("n", "", "j", opts) -map("n", "", "k", opts) --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Indent ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ +-------------------- Stay in indent mode ------------------------ +map("v", "<", "", ">gv", { desc = "Indent right" }) +map("v", "p", '"_dP') -map("v", "<", "", ">gv", opts) -map("v", "p", '"_dP', opts) +-------------------- Resize windows ---------------------------- +map("n", "", "resize +2", { desc = "Increase window height" }) +map("n", "", "resize -2", { desc = "Decrease window height" }) +map("n", "", "vertical resize -2", { desc = "Decrease window width" }) +map("n", "", "vertical resize +2", { desc = "Increase window width" }) --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Resize Window ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ - -map("n", "", ":resize +1", opts) -map("n", "", ":resize -1", opts) -map("n", "", ":vertical resize +1", opts) -map("n", "", ":vertical resize -1", opts) - --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Move Lines ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ - --- Visual -- -map("v", "", ":m .+1==", opts) -map("v", "", ":m .-2==", opts) --- Block -- -map("x", "", ":move '>+1gv-gv", opts) -map("x", "", ":move '<-2gv-gv", opts) +-------------------- Move text up/ down ------------------------ -- Normal -- -map("n", "", ":m .+1==", opts) -map("n", "", ":m .-2==", opts) +map("n", "", "m .+1==", { desc = "Move down" }) +map("n", "", "m .-2==", { desc = "Move up" }) +-- Block -- +map("x", "", ":move '>+1gv-gv", { desc = "Move down" }) +map("x", "", ":move '<-2gv-gv", { desc = "Move up" }) -- Insert -- -map("i", "", ":m .+1==gi", opts) -map("i", "", ":m .-2==gi", opts) - --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ No highlight ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ - -map("n", ";", ":noh", opts) - --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Split Windows ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ - -map("n", "\\", ":vsplit", opts) -map("n", "/", ":split", opts) - --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Compile ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ - -map("n", "", "only | Compile", opts) - --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Inspect ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ - -map("n", "", "Inspect", opts) --- +---------------------------------------------------------------+ --- paste over currently selected text without yanking it -map("v", "p", '"_dp', opts) -map("v", "P", '"_dP', opts) - --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ switch buffer ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ +map("i", "", "m .+1==gi", { desc = "Move down" }) +map("i", "", "m .-2==gi", { desc = "Move up" }) +-- Visual -- +map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) +map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) -map("n", "", "bnext", { desc = "Next buffer" }) -map("n", "", "bprevious", { desc = "Prev buffer" }) +-------------------- No highlight ------------------------------ +map("n", ";", ":noh", { desc = "Clear search" }) --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Sort selected lines alphabetically ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ +-------------------- Inspect -------------------------------- +map("n", "", "Inspect", { desc = "Inspect highlight fallback" }) -map("v", "", "Sort ", { desc = "Sort Lines Alphabetically" }) +-------------------- split window ------------------------------ +map("n", "\\", ":vsplit", { desc = "Split window vertically" }) +map("n", "/", ":split", { desc = "Split window horizontally" }) --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Terminal ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ +-------------------- Switch two windows ------------------------ +map("n", "", "r", { desc = "Rotate window" }) -map("t", "", "", { noremap = true, silent = true }) -- back to normal mode in Terminal -map("t", "", [[h]], { noremap = true }) -map("t", "", [[j]], { noremap = true }) -map("t", "", [[k]], { noremap = true }) -map("t", "", [[l]], { noremap = true }) +------------------- Select all ----------------------------- +map("n", "", "ggG", { desc = "Select all" }) --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Save Function ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ +-------------------- Fuzzy Search -------------------------------- +vim.keymap.set("n", "", function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes")) +end, { desc = "[/] Fuzzily search in current buffer]" }) -map("v", "", "wa", { desc = "Save file" }) -map("i", "", "wa", { desc = "Save file" }) -map("n", "", "wa", { desc = "Save file" }) -map("x", "", "wa", { desc = "Save file" }) +-------------------Save Function--------------------------- +map("v", "", "wa!", { desc = "Save file" }) +map("i", "", "wa!", { desc = "Save file" }) +map("n", "", "wa!", { desc = "Save file" }) +map("x", "", "wa!", { desc = "Save file" }) --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Comment Box ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ -map("v", "Cn", "CBlcbox13", { desc = "Comment Box Multi-Line Notation" }) -map("v", "Cs", "CBlrbox19", { desc = "Sub-Heading Comment Box" }) -map("v", "Ch", "CBlcbox8", { desc = "Heading Comment Box" }) +--------------------Comment Bars--------------------- map("v", "", "CBline7", { desc = "comment line" }) map("i", "", "CBline7", { desc = "comment line" }) map("n", "", "CBline7", { desc = "comment line" }) -map("v", "", "CBline6", { desc = "alternative comment line" }) -map("i", "", "CBline6", { desc = "alternative comment line" }) -map("n", "", "CBline6", { desc = "alternative comment line" }) -map("n", "C?", "CBcatalog", { desc = "Comment Box Style Catalog" }) -map("n", "Cn", "CBlcbox13", { desc = "Comment Box Multi-Line Notation" }) -map("n", "Cs", "CBlrbox19", { desc = "Sub-Heading Comment Box" }) -map("n", "Ch", "CBlcbox5", { desc = "Heading Comment Box" }) - --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Fuzzy Search ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ - -vim.keymap.set("n", "", function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes")) -end, { desc = "[/] Fuzzily search in current buffer]" }) +map("v", "", "CBline15", { desc = "alternative comment line" }) +map("i", "", "CBline15", { desc = "alternative comment line" }) +map("n", "", "CBline15", { desc = "alternative comment line" }) diff --git a/lua/core/lazy.lua b/lua/core/lazy.lua old mode 100755 new mode 100644 index 4a722a2..d4dc17c --- a/lua/core/lazy.lua +++ b/lua/core/lazy.lua @@ -1,4 +1,6 @@ +local Icons = require("core").icons local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", @@ -15,34 +17,64 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup({ spec = { { import = "plugins" }, - { import = "plugins.lang.markdown", enabled = true }, - { import = "plugins.lang.nix", enabled = true }, - { import = "plugins.lang.rust", enabled = true }, - { import = "plugins.lang.python", enabled = true }, - { import = "plugins.lang.php", enabled = true }, - { import = "plugins.lang.typescript", enabled = true }, - { import = "plugins.lang.json", enabled = true }, - { import = "plugins.lang.java", enabled = false }, - { import = "plugins.lang.docker", enabled = true }, - { import = "plugins.lang.clangd", enabled = false }, + { import = "features.lsp.lang.docker", enabled = true }, + { import = "features.lsp.lang.flutter", enabled = true }, + { import = "features.lsp.lang.go", enabled = true }, + { import = "features.lsp.lang.java", enabled = false }, + { import = "features.lsp.lang.json", enabled = true }, + { import = "features.lsp.lang.markdown", enabled = true }, + { import = "features.lsp.lang.markup", enabled = true }, + { import = "features.lsp.lang.nix", enabled = true }, + { import = "features.lsp.lang.python", enabled = true }, + { import = "features.lsp.lang.rust", enabled = true }, + { import = "features.lsp.lang.typescript", enabled = true }, + { import = "features.lsp.lang.vue", enabled = false }, }, defaults = { - lazy = false, - version = false, -- always use the latest git commit - -- version = "*", -- try installing the latest stable version for plugins that support semver + lazy = true, + -- version = false, -- always use the latest git commit + version = "*", -- try installing the latest stable version for plugins that support semver }, install = { colorscheme = { "monokai-pro" } }, - checker = { enabled = true, notify = false }, + checker = { enabled = false, notify = false }, + ui = { + icons = { + ft = Icons.lazy.ft, + lazy = Icons.lazy.lazy, + loaded = Icons.lazy.loaded, + not_loaded = Icons.lazy.not_loaded, + }, + }, performance = { rtp = { -- disable some rtp plugins disabled_plugins = { + "2html_plugin", + "tohtml", + "getscript", + "getscriptPlugin", "gzip", + "logipat", + "netrw", "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "tar", "tarPlugin", - "tohtml", - "tutor", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", "zipPlugin", + "tutor", + "rplugin", + "syntax", + "synmenu", + "optwin", + "compiler", + "bugreport", + "ftplugin", }, }, }, diff --git a/lua/core/logo.lua b/lua/core/logos.lua similarity index 64% rename from lua/core/logo.lua rename to lua/core/logos.lua index 698d028..732860e 100755 --- a/lua/core/logo.lua +++ b/lua/core/logos.lua @@ -1,5 +1,4 @@ local M = { - days_of_week = {}, logos = {}, } @@ -266,70 +265,6 @@ local logos = { ]], } -local days_of_week = { - Monday = [[ -███╗ ███╗ ██████╗ ███╗ ██╗██████╗ █████╗ ██╗ ██╗ -████╗ ████║██╔═══██╗████╗ ██║██╔══██╗██╔══██╗╚██╗ ██╔╝ -██╔████╔██║██║ ██║██╔██╗ ██║██║ ██║███████║ ╚████╔╝⠀ -██║╚██╔╝██║██║ ██║██║╚██╗██║██║ ██║██╔══██║ ╚██╔╝⠀⠀ -██║ ╚═╝ ██║╚██████╔╝██║ ╚████║██████╔╝██║ ██║ ██║⠀⠀⠀ -╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═════╝ ╚═╝ ╚═╝ ╚═╝⠀⠀⠀ - ]], - Tuesday = [[ -████████╗██╗ ██╗███████╗███████╗██████╗ █████╗ ██╗ ██╗ -╚══██╔══╝██║ ██║██╔════╝██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝ - ██║ ██║ ██║█████╗ ███████╗██║ ██║███████║ ╚████╔╝⠀ - ██║ ██║ ██║██╔══╝ ╚════██║██║ ██║██╔══██║ ╚██╔╝⠀⠀ - ██║ ╚██████╔╝███████╗███████║██████╔╝██║ ██║ ██║⠀⠀⠀ - ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═╝⠀⠀⠀ - ]], - Wednesday = [[ -██╗ ██╗███████╗██████╗ ███╗ ██╗███████╗███████╗██████╗ █████╗ ██╗ ██╗ -██║ ██║██╔════╝██╔══██╗████╗ ██║██╔════╝██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝ -██║ █╗ ██║█████╗ ██║ ██║██╔██╗ ██║█████╗ ███████╗██║ ██║███████║ ╚████╔╝⠀ -██║███╗██║██╔══╝ ██║ ██║██║╚██╗██║██╔══╝ ╚════██║██║ ██║██╔══██║ ╚██╔╝⠀⠀ -╚███╔███╔╝███████╗██████╔╝██║ ╚████║███████╗███████║██████╔╝██║ ██║ ██║⠀⠀⠀ - ╚══╝╚══╝ ╚══════╝╚═════╝ ╚═╝ ╚═══╝╚══════╝╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═╝⠀⠀⠀ - ]], - Thursday = [[ -████████╗██╗ ██╗██╗ ██╗██████╗ ███████╗██████╗ █████╗ ██╗ ██╗ -╚══██╔══╝██║ ██║██║ ██║██╔══██╗██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝ - ██║ ███████║██║ ██║██████╔╝███████╗██║ ██║███████║ ╚████╔╝⠀ - ██║ ██╔══██║██║ ██║██╔══██╗╚════██║██║ ██║██╔══██║ ╚██╔╝⠀⠀ - ██║ ██║ ██║╚██████╔╝██║ ██║███████║██████╔╝██║ ██║ ██║⠀⠀⠀ - ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═╝⠀⠀⠀ - ]], - Friday = [[ -███████╗██████╗ ██╗██████╗ █████╗ ██╗ ██╗ -██╔════╝██╔══██╗██║██╔══██╗██╔══██╗╚██╗ ██╔╝ -█████╗ ██████╔╝██║██║ ██║███████║ ╚████╔╝⠀ -██╔══╝ ██╔══██╗██║██║ ██║██╔══██║ ╚██╔╝⠀⠀ -██║ ██║ ██║██║██████╔╝██║ ██║ ██║⠀⠀⠀ -╚═╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝⠀⠀⠀ - ]], - Saturday = [[ -███████╗ █████╗ ████████╗██╗ ██╗██████╗ ██████╗ █████╗ ██╗ ██╗ -██╔════╝██╔══██╗╚══██╔══╝██║ ██║██╔══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝ -███████╗███████║ ██║ ██║ ██║██████╔╝██║ ██║███████║ ╚████╔╝⠀ -╚════██║██╔══██║ ██║ ██║ ██║██╔══██╗██║ ██║██╔══██║ ╚██╔╝⠀⠀ -███████║██║ ██║ ██║ ╚██████╔╝██║ ██║██████╔╝██║ ██║ ██║⠀⠀⠀ -╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝⠀⠀⠀ - ]], - Sunday = [[ -███████╗██╗ ██╗███╗ ██╗██████╗ █████╗ ██╗ ██╗ -██╔════╝██║ ██║████╗ ██║██╔══██╗██╔══██╗╚██╗ ██╔╝ -███████╗██║ ██║██╔██╗ ██║██║ ██║███████║ ╚████╔╝⠀ -╚════██║██║ ██║██║╚██╗██║██║ ██║██╔══██║ ╚██╔╝⠀⠀ -███████║╚██████╔╝██║ ╚████║██████╔╝██║ ██║ ██║⠀⠀⠀ -╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚═════╝ ╚═╝ ╚═╝ ╚═╝⠀⠀⠀ - ]], -} - -M.days_of_week.generate = function() - local current_day = os.date("%A") - return vim.split("\n\n\n" .. days_of_week[current_day] .. "\n\n" .. os.date("%Y-%m-%d %H:%M:%S" .. "\n"), "\n") -end - --- @param type "saturn" | "saturn_plus" | "earth" | "rowan_cap" | "graffiti" | "ogre" | "slant_relief" | "ansi_shadow" | "delta_corps_priest1" | "colossal" | "def_leppard" | "sharp" M.logos.generate = function(type) return vim.split("\n" .. logos[type], "\n") diff --git a/lua/core/options.lua b/lua/core/options.lua old mode 100755 new mode 100644 index bf675a2..ef8014a --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -101,13 +101,9 @@ vim.g.loaded_netrwPlugin = 1 vim.g.mapleader = " " vim.g.maplocalleader = " " - - vim.opt.shortmess:append("c") vim.opt.viewoptions:remove("curdir") -- disable saving current directory with views - - vim.opt.list = true -- vim.opt.listchars:append "space:⋅" -- vim.opt.listchars:append "eol:↴" diff --git a/lua/features/lsp/diagnostics.lua b/lua/features/lsp/diagnostics.lua new file mode 100644 index 0000000..d7dd4f8 --- /dev/null +++ b/lua/features/lsp/diagnostics.lua @@ -0,0 +1,71 @@ +local Utils = require("utils") +local Icons = require("core").icons + +---@class LspDiagnostics +---@field enabled boolean + +---@class features.lsp.diagnostics +local M = {} + +setmetatable(M, { + __call = function(m, ...) + return m.setup(...) + end, +}) + +local function on() + M.enabled = true + vim.diagnostic.config({ + virtual_text = { + spacing = 4, + source = "if_many", + prefix = "●", + }, -- disable virtual text + virtual_lines = false, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = false, + style = "minimal", + border = Utils.telescope.borderchars("thick", "tl-t-tr-r-br-b-bl-l"), + source = "always", + header = "", + prefix = "", + }, + }) +end + +local function off() + M.enabled = false + vim.diagnostic.config({ + underline = true, + virtual_text = false, + signs = false, + update_in_insert = false, + }) +end + +---@param enabled boolean +function M.setup(enabled) + for name, icon in pairs(Icons.diagnostics) do + name = "DiagnosticSign" .. Utils.string.capitalize(name) + vim.fn.sign_define(name, { text = icon, texthl = name, numhl = name }) + end + if enabled then + on() + else + off() + end + + -- Setup command + vim.api.nvim_create_user_command("ToggleDiagnostic", function() + if M.enabled then + off() + else + on() + end + end, { nargs = 0 }) +end + +return M diff --git a/lua/features/lsp/init.lua b/lua/features/lsp/init.lua new file mode 100644 index 0000000..75bf14c --- /dev/null +++ b/lua/features/lsp/init.lua @@ -0,0 +1,94 @@ +local Utils = require("utils") + +---@class LspServer +---@field keys? string|string[]|LazyKeysSpec[]|fun(self:LazyPlugin, keys:string[]):(string|LazyKeys)[] +---@field capabilities? table +---@field on_attach? fun(client, bufnr) + +---@class LspOptions +---@field servers table +---@field capabilities? table +---@field diagnostics? boolean + +---@class Lsp +---@field keymaps features.lsp.keymaps +---@field navic features.lsp.navic +---@field diagnostics features.lsp.diagnostics +local M = {} + +setmetatable(M, { + __index = function(_, k) + local mod = require("features.lsp." .. k) + return mod + end, +}) + +---@param opts LspOptions +function M.setup(opts) + local ok, lspconfig = pcall(require, "lspconfig") + if not ok then + Utils.notify("Plugin `neovim/nvim-lspconfig` not installed", "ERROR") + return + end + -- Diagnostics + M.diagnostics.setup(opts.diagnostics) + + -- Keymaps + Utils.lsp.on_attach(function(client, bufnr) + M.keymaps(client, bufnr) + M.navic(client, bufnr) + end) + + local servers = opts.servers + -- Gets a new ClientCapabilities object describing the LSP client capabilities. + local client_capabilites = vim.lsp.protocol.make_client_capabilities() + + local capabilities = vim.tbl_deep_extend( + "force", + {}, + client_capabilites, + require("cmp_nvim_lsp").default_capabilities(), + opts.capabilities or {} + ) + + --- Setup a LSP server + ---@param server string The name of the server + local function setup(server) + -- resolve server capabilities + if servers[server] and servers[server].capabilities and type(servers[server].capabilities) == "function" then + servers[server].capabilities = servers[server].capabilities() or {} + end + + local server_opts = vim.tbl_deep_extend("force", { + capabilities = vim.deepcopy(capabilities), + }, servers[server] or {}) + + if server_opts.on_attach then + local function callback(client, bufnr) + if client.name == server then + server_opts.on_attach(client, bufnr) + end + end + Utils.lsp.on_attach(callback) + end + lspconfig[server].setup(server_opts) + end + + local available = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) + + local ensure_installed = {} + for server, server_opts in pairs(servers) do + if server_opts then + if not vim.tbl_contains(available, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end + end + end + + require("mason-lspconfig").setup({ ensure_installed = ensure_installed }) + require("mason-lspconfig").setup_handlers({ setup }) +end + +return M diff --git a/lua/plugins/config/lsp/keymaps.lua b/lua/features/lsp/keymaps.lua old mode 100755 new mode 100644 similarity index 52% rename from lua/plugins/config/lsp/keymaps.lua rename to lua/features/lsp/keymaps.lua index 110013c..7963172 --- a/lua/plugins/config/lsp/keymaps.lua +++ b/lua/features/lsp/keymaps.lua @@ -1,13 +1,24 @@ -local M = {} +local Utils = require("utils") +---@class features.lsp.keymaps +local M = setmetatable({}, { + __call = function(m, ...) + return m.attach(...) + end, +}) + +---@return LazyKeysSpec[] function M.get() return { { "la", "lua vim.lsp.buf.code_action()", desc = "Code Action" }, - { "ld", "Telescope diagnostics bufnr=0s", desc = "Document Diagnostics" }, - { "lw", "Telescope diagnostics", desc = "Workspace Diagnostics" }, - { "li", "Telescope LspInfo", desc = "Info" }, - { "lj", "lua vim.diagnostic.goto_next()", desc = "Next Diagnostic" }, - { "lk", "lua vim.diagnostic.goto_prev()", desc = "Prev Diagnostic" }, + { "ld", "Telescope lsp_document_diagnostics", desc = "Document Diagnostics" }, + { "lw", "Telescope lsp_workspace_diagnostics", desc = "Workspace Diagnostics" }, + -- stylua: ignore + { "lh", function() vim.lsp.inlay_hint(0, nil) end,desc = "Toggle inlay hints"}, + { "li", "LspInfo", desc = "Info" }, + { "lI", "LspInstallInfo", desc = "Installer Info" }, + { "lj", "lua vim.lsp.diagnostic.goto_next()", desc = "Next Diagnostic" }, + { "lk", "lua vim.lsp.diagnostic.goto_prev()", desc = "Prev Diagnostic" }, { "ll", "lua vim.lsp.codelens.run()", desc = "CodeLens Action" }, { "lq", "lua vim.lsp.diagnostic.set_loclist()", desc = "Quickfix" }, { "lr", "lua vim.lsp.buf.rename()", desc = "Rename" }, @@ -18,46 +29,37 @@ function M.get() { "gr", "Telescope lsp_references", desc = "Go to references" }, { "gi", "Telescope lsp_implementations", desc = "Go to implementations" }, { "K", "lua vim.lsp.buf.hover()", desc = "Hover" }, + { "gl", "lua vim.diagnostic.open_float()", desc = "Show diagnostics" }, { "]d", "lua vim.diagnostic.goto_prev({buffer=0})", desc = "Prev Diagnostic" }, { "[d", "lua vim.diagnostic.goto_next({buffer=0})", desc = "Next Diagnostic" }, + { "lq", "lua vim.diagnostic.setloclist()", desc = "Quickfix" }, } end -function M.resolve(buffer) +---@return LazyKeys +function M.resolve(bufnr) local Keys = require("lazy.core.handler.keys") - local keymaps = {} - - local function add(keymap) - local keys = Keys.parse(keymap) - if keys[2] == false then - keymaps[keys.id] = nil - else - keymaps[keys.id] = keys - end - end - for _, keymap in ipairs(M.get()) do - add(keymap) - end + local spec = M.get() - local opts = require("util").opts("nvim-lspconfig") - local clients = vim.lsp.get_active_clients({ bufnr = buffer }) + ---@type LspOptions + local opts = Utils.plugin.opts("nvim-lspconfig") + local clients = vim.lsp.get_active_clients({ bufnr = bufnr }) for _, client in ipairs(clients) do local maps = opts.servers[client.name] and opts.servers[client.name].keys or {} - for _, keymap in ipairs(maps) do - add(keymap) - end + vim.list_extend(spec, maps) end - return keymaps + return Keys.resolve(spec) end -M.attach = function(_, buffer) +function M.attach(_, bufnr) local Keys = require("lazy.core.handler.keys") - local keymaps = M.resolve(buffer) + local keymaps = M.resolve(bufnr) for _, keys in pairs(keymaps) do local opts = Keys.opts(keys) + opts.has = nil opts.silent = opts.silent ~= false - opts.buffer = buffer + opts.buffer = bufnr vim.keymap.set(keys.mode or "n", keys.lhs, keys.rhs, opts) end end diff --git a/lua/plugins/lang/docker.lua b/lua/features/lsp/lang/docker.lua similarity index 100% rename from lua/plugins/lang/docker.lua rename to lua/features/lsp/lang/docker.lua diff --git a/lua/features/lsp/lang/flutter.lua b/lua/features/lsp/lang/flutter.lua new file mode 100644 index 0000000..7f228ec --- /dev/null +++ b/lua/features/lsp/lang/flutter.lua @@ -0,0 +1,35 @@ +return { + { + "akinsho/flutter-tools.nvim", + ft = "dart", + dependencies = { + "nvim-lua/plenary.nvim", + "stevearc/dressing.nvim", -- optional for vim.ui.select + }, + opts = { + lsp = { + color = { + enabled = true, + background = true, + virtual_text = false, + }, + settings = { + showTodos = false, + renameFilesWithClasses = "always", + updateImportsOnRename = true, + completeFunctionCalls = true, + lineLength = 100, + }, + }, + }, + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "dart" }) + end + end, + }, +} diff --git a/lua/features/lsp/lang/go.lua b/lua/features/lsp/lang/go.lua new file mode 100644 index 0000000..bfea3ad --- /dev/null +++ b/lua/features/lsp/lang/go.lua @@ -0,0 +1,87 @@ +return { + -- Ensure Go tools are installed + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt" }) + end, + }, + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { + "go", + "gomod", + "gowork", + "gosum", + }) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + gopls = { + settings = { + gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, + semanticTokens = true, + }, + }, + on_attach = function(client, _) + if not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { + tokenTypes = semantic.tokenTypes, + tokenModifiers = semantic.tokenModifiers, + }, + range = true, + } + end + end, + }, + }, + }, + }, + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + go = { "goimports", "gofumpt" }, + }, + }, + }, +} diff --git a/lua/plugins/lang/java.lua b/lua/features/lsp/lang/java.lua similarity index 100% rename from lua/plugins/lang/java.lua rename to lua/features/lsp/lang/java.lua diff --git a/lua/plugins/lang/json.lua b/lua/features/lsp/lang/json.lua similarity index 100% rename from lua/plugins/lang/json.lua rename to lua/features/lsp/lang/json.lua diff --git a/lua/plugins/lang/markdown.lua b/lua/features/lsp/lang/markdown.lua similarity index 100% rename from lua/plugins/lang/markdown.lua rename to lua/features/lsp/lang/markdown.lua diff --git a/lua/features/lsp/lang/markup.lua b/lua/features/lsp/lang/markup.lua new file mode 100644 index 0000000..b573eb3 --- /dev/null +++ b/lua/features/lsp/lang/markup.lua @@ -0,0 +1,82 @@ +return { + { + "mattn/emmet-vim", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + init = function() + vim.g.user_emmet_leader_key = "f" + vim.g.user_emmet_mode = "n" + vim.g.user_emmet_settings = { + variables = { lang = "ja" }, + javascript = { + extends = "jsx", + }, + html = { + default_attributes = { + option = { value = vim.null }, + textarea = { + id = vim.null, + name = vim.null, + cols = 10, + rows = 10, + }, + }, + snippets = { + ["!"] = "\n" + .. '\n' + .. "\n" + .. '\t\n' + .. '\t\n' + .. '\t\n' + .. "\t\n" + .. "\n" + .. "\n\t${child}|\n\n" + .. "", + }, + }, + } + end, + }, + + { + "windwp/nvim-ts-autotag", + ft = { + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "svelte", + "vue", + "tsx", + "jsx", + "rescript", + "xml", + "php", + "markdown", + "glimmer", + "handlebars", + "hbs", + }, + opts = { + enable = true, + filetypes = { + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "svelte", + "vue", + "tsx", + "jsx", + "rescript", + "xml", + "php", + "markdown", + "glimmer", + "handlebars", + "hbs", + }, + }, + }, +} diff --git a/lua/plugins/lang/nix.lua b/lua/features/lsp/lang/nix.lua similarity index 100% rename from lua/plugins/lang/nix.lua rename to lua/features/lsp/lang/nix.lua diff --git a/lua/plugins/lang/php.lua b/lua/features/lsp/lang/php.lua similarity index 100% rename from lua/plugins/lang/php.lua rename to lua/features/lsp/lang/php.lua diff --git a/lua/plugins/lang/python.lua b/lua/features/lsp/lang/python.lua similarity index 100% rename from lua/plugins/lang/python.lua rename to lua/features/lsp/lang/python.lua diff --git a/lua/plugins/lang/rust.lua b/lua/features/lsp/lang/rust.lua similarity index 100% rename from lua/plugins/lang/rust.lua rename to lua/features/lsp/lang/rust.lua diff --git a/lua/plugins/lang/typescript.lua b/lua/features/lsp/lang/typescript.lua similarity index 100% rename from lua/plugins/lang/typescript.lua rename to lua/features/lsp/lang/typescript.lua diff --git a/lua/features/lsp/lang/vue.lua b/lua/features/lsp/lang/vue.lua new file mode 100644 index 0000000..6d73a21 --- /dev/null +++ b/lua/features/lsp/lang/vue.lua @@ -0,0 +1,44 @@ +return { + { + "williamboman/mason.nvim", + opts = function(_, opts) + table.insert(opts.ensure_installed, "black") + end, + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "vue", "css", "scss", "html", "json" }) + end + end, + }, + + { + "nvim-lspconfig", + opts = { + servers = { + volar = { + filetypes = { + "vue", + "javascript", + "javascript.jsx", + "typescript", + "typescript.tsx", + "javascriptreact", + "typescriptreact", + "json", + }, + }, + tsserver = { + autostart = false, + root_dir = function() + return false + end, + single_file_support = false, + }, + }, + }, + }, +} diff --git a/lua/features/lsp/navic.lua b/lua/features/lsp/navic.lua new file mode 100644 index 0000000..8506b89 --- /dev/null +++ b/lua/features/lsp/navic.lua @@ -0,0 +1,19 @@ +---@class features.lsp.navic +local M = setmetatable({}, { + __call = function(m, ...) + return m.attach(...) + end, +}) + +function M.attach(client, bufnr) + local status_ok, navic = pcall(require, "nvim-navic") + if not status_ok then + return + end + + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end +end + +return M diff --git a/lua/features/lualine/components.lua b/lua/features/lualine/components.lua new file mode 100644 index 0000000..5937319 --- /dev/null +++ b/lua/features/lualine/components.lua @@ -0,0 +1,234 @@ +local Utils = require("utils") +local Icons = require("core").icons +local palette = require("features.lualine.palette") +local config = require("features.lualine.config") + +---@class LualineComponentStore +local cpn = {} + +---@class LualineComponents: LualineComponentStore +local M = setmetatable({}, { + __index = function(_, k) + return rawget(cpn or {}, k) + end, + __newindex = function(t, k, v) + if rawget(cpn or {}, k) ~= nil then + error("Lualine: Attempt to change option " .. k .. " directly, use `setup` instead") + else + rawset(t, k, v) + end + end, +}) + +---@param sep_type? LualineSeparatorType +function cpn.branch(sep_type) + return { + "branch", + icons_enabled = false, + colored = false, + fmt = function(text) + if text == "" or text == nil then + text = "!=vcs" + end + -- return build_component(" " .. truncate(text, 10), type, hl_value) + return Utils.lualine.build_component(config, { + { text = " ", color = palette.white }, + { text = text, color = palette.green }, + }, sep_type or "fill") + end, + } +end + +---@param sep_type? LualineSeparatorType +function cpn.diagnostics(sep_type) + local function nvim_diagnostic() + local diagnostics = vim.diagnostic.get(0) + local count = { 0, 0, 0, 0 } + for _, diagnostic in ipairs(diagnostics) do + count[diagnostic.severity] = count[diagnostic.severity] + 1 + end + return count[vim.diagnostic.severity.ERROR], + count[vim.diagnostic.severity.WARN], + count[vim.diagnostic.severity.INFO], + count[vim.diagnostic.severity.HINT] + end + + return function() + local error_count, warn_count, info_count, hint_count = nvim_diagnostic() + return Utils.lualine.build_component(config, { + { text = Icons.diagnostics.error .. " " .. error_count, color = palette.red }, + { text = Icons.diagnostics.warn .. " " .. warn_count, color = palette.yellow }, + { text = Icons.diagnostics.info .. " " .. info_count, color = palette.blue }, + { text = Icons.diagnostics.hint .. " " .. hint_count, color = palette.green }, + }, sep_type or "thin", nil, " ") + end +end + +---@param sep_type? LualineSeparatorType +function cpn.diff(sep_type) + sep_type = sep_type or "thin" + local added_hl_gr = Utils.lualine.get_hl_gr("Added") + local modified_hl_gr = Utils.lualine.get_hl_gr("Modified") + local removed_hl_gr = Utils.lualine.get_hl_gr("Removed") + return { + "diff", + colored = true, + diff_color = { + added = added_hl_gr, + modified = modified_hl_gr, + removed = removed_hl_gr, + }, + symbols = { + added = Icons.git.added .. " ", + modified = Icons.git.modified .. " ", + removed = Icons.git.removed .. " ", + }, -- changes diff symbols + fmt = function(text) + if text == "" then + return "" + end + Utils.once(function() + local bg = Utils.lualine.get_component_bg(sep_type) + vim.api.nvim_set_hl(0, added_hl_gr, { fg = palette.green, bg = bg }) + vim.api.nvim_set_hl(0, modified_hl_gr, { fg = palette.yellow, bg = bg }) + vim.api.nvim_set_hl(0, removed_hl_gr, { fg = palette.red, bg = bg }) + end) + return Utils.lualine.build_component(config, { + { text = text, color = palette.red }, + }, sep_type) + end, + cond = Utils.lualine.hide_width, + } +end + +---@param sep_type? LualineSeparatorType +function cpn.position(sep_type) + return function() + local current_line = vim.fn.line(".") + local current_column = vim.fn.col(".") + local text = "Ln " .. current_line .. ", Col " .. current_column + return Utils.lualine.build_component(config, { + { text = text, color = palette.magenta }, + }, sep_type or "fill") + end +end + +local prev_ft = "" +---@param sep_type? LualineSeparatorType +function cpn.filetype(sep_type) + return { + "filetype", + icons_enabled = false, + icons_only = false, + fmt = function(text) + local ui_filetypes = { + "help", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "neo-tree", + "", + } + local ft_text = "" + + if text == "toggleterm" then + --  + ft_text = "ToggleTerm " .. vim.api.nvim_buf_get_var(0, "toggle_number") + elseif text == "TelescopePrompt" then + ft_text = "" + elseif text == "neo-tree" or text == "neo-tree-popup" then + if prev_ft == "" then + return + end + ft_text = prev_ft + elseif text == "help" then + ft_text = "󰋖" + elseif vim.tbl_contains(ui_filetypes, text) then + return + else + prev_ft = text + ft_text = text + end + ft_text = Utils.string.capitalize(ft_text) + return Utils.lualine.build_component(config, { + { text = ft_text, color = palette.blue }, + }, sep_type or "fill") + end, + } +end + +---@param sep_type? LualineSeparatorType +function cpn.spaces(sep_type) + return function() + local text = "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") + return Utils.lualine.build_component(config, { + { text = text, color = palette.yellow }, + }, sep_type or "fill") + end +end + +---@param sep_type? LualineSeparatorType +function cpn.mode(sep_type) + return { + "mode", + fmt = function(text) + return Utils.lualine.build_component(config, { + { text = text, color = palette.green }, + }, sep_type or "fill") + end, + } +end + +---@param sep_type? LualineSeparatorType +function cpn.ai_source(sources, sep_type) + local cmp_source = false + ---Status of the source + ---@param name string The name of the source + ---@return "ok"|"pending"|"error"? + local function status(name) + if not package.loaded.cmp then + return + end + for _, s in ipairs(require("cmp").core.sources) do + if s.name == name then + if s.source:is_available() then + cmp_source = true + else + return cmp_source and "error" or nil + end + if s.status == s.SourceStatus.FETCHING then + return "pending" + end + return "ok" + end + end + end + return { + function() + local texts = {} + for _, source in ipairs(sources) do + local s = status(source) + if s then + local colors = { + ok = Icons.colors.brain[source], + pending = Utils.theme.highlight("Whitespace").fg, + error = Utils.theme.highlight("DiagnosticError").fg, + } + table.insert(texts, { text = Icons.brain[source], color = colors[s] }) + end + end + return Utils.lualine.build_component(config, texts, sep_type or "fill", nil, " ") + end, + cond = function() + return Utils.table.any(sources, status) + end, + } +end + +return M diff --git a/lua/features/lualine/config.lua b/lua/features/lualine/config.lua new file mode 100644 index 0000000..209f282 --- /dev/null +++ b/lua/features/lualine/config.lua @@ -0,0 +1,34 @@ +---@class LualineOptions +local options = { + float = true, + colorful = true, + ---@enum (key) LualineSeparatorType + separator = { + fill = { left = "", right = "" }, + thin = { left = "", right = "" }, + }, +} + +---@class LualineConfig: LualineOptions +local M = setmetatable({}, { + __index = function(_, k) + return rawget(options or {}, k) + end, + __newindex = function(t, k, v) + if rawget(options or {}, k) ~= nil then + error("Lualine: Attempt to change option " .. k .. " directly, use `setup` instead") + else + rawset(t, k, v) + end + end, + __call = function(t, ...) + return t.setup(...) + end, +}) + +---@param opts LualineOptions +function M.setup(opts) + options = vim.tbl_deep_extend("force", options, opts or {}) +end + +return M diff --git a/lua/plugins/config/lualine/init.lua b/lua/features/lualine/init.lua old mode 100755 new mode 100644 similarity index 55% rename from lua/plugins/config/lualine/init.lua rename to lua/features/lualine/init.lua index ad72cf7..07f4691 --- a/lua/plugins/config/lualine/init.lua +++ b/lua/features/lualine/init.lua @@ -1,11 +1,17 @@ -local config = require("plugins.config.lualine.config") +local Utils = require("utils") +local config = require("features.lualine.config") local M = {} -local function setup() - local cpn = require("plugins.config.lualine.components") - local theme = require("plugins.config.lualine.highlights").custom(config.options) +M.setup = config.setup + +function M._load() + local theme = require("features.lualine.theme")(config) + local _ = require("features.lualine.palette")(config) + local cpn = require("features.lualine.components") + -- palette.setup() + ---@diagnostic disable-next-line: undefined-field require("lualine").setup({ options = { theme = theme, @@ -21,16 +27,16 @@ local function setup() refresh = { statusline = 1000, tabline = 1000, - -- winbar = 100, + winbar = 100, }, }, sections = { - lualine_a = { cpn.branch }, - lualine_b = { cpn.diagnostics }, + lualine_a = { cpn.branch() }, + lualine_b = { cpn.diagnostics() }, lualine_c = {}, - lualine_x = { cpn.diff }, - lualine_y = { cpn.position, cpn.filetype }, - lualine_z = { cpn.spaces, cpn.mode }, + lualine_x = { cpn.diff(), cpn.ai_source({ "copilot", "codeium" }) }, + lualine_y = { cpn.position(), cpn.filetype() }, + lualine_z = { cpn.spaces(), cpn.mode() }, }, inactive_sections = { lualine_a = {}, @@ -45,13 +51,13 @@ local function setup() }) end -M.setup = config.setup - -M.load = function() - setup() +function M.load() + M._load() + local group = Utils.augroup("Lualine") vim.api.nvim_create_autocmd("ColorScheme", { + group = group, callback = function() - setup() + M._load() end, }) end diff --git a/lua/features/lualine/palette.lua b/lua/features/lualine/palette.lua new file mode 100644 index 0000000..b7cbe84 --- /dev/null +++ b/lua/features/lualine/palette.lua @@ -0,0 +1,61 @@ +local Utils = require("utils") + +---@class DefaultLualinePalette +local palette = { + yellow = "#ffff00", + white = "#ffffff", + red = "#ff0000", + orange = "#ff7700", + blue = "#00ffff", + magenta = "#ff00ff", + green = "#00ff00", +} + +---@class LualinePalette: DefaultLualinePalette +local M = setmetatable({}, { + __index = function(_, k) + return rawget(palette or {}, k) + end, + __newindex = function(t, k, v) + if rawget(palette or {}, k) ~= nil then + error("Lualine: Attempt to change option " .. k .. " directly, use `setup` instead") + else + rawset(t, k, v) + end + end, + __call = function(m, ...) + return m.setup(...) + end, +}) + +---@param config LualineOptions +function M.setup(config) + local BAR_FG = Utils.theme.highlight("StatusLine").fg or "#aaaaaa" + local colorful = config.colorful + local highlight = Utils.theme.highlight + + if colorful then + palette = vim.tbl_deep_extend("force", palette, { + yellow = highlight("String").fg, + white = highlight("Normal").fg, + red = highlight("DiagnosticError").fg, + orange = highlight("DiagnosticWarn").fg, + blue = highlight("DiagnosticHint").fg, + magenta = highlight("Statement").fg, + green = highlight("healthSuccess").fg, + }) + else + palette = vim.tbl_deep_extend("force", palette, { + yellow = BAR_FG, + white = BAR_FG, + red = BAR_FG, + orange = BAR_FG, + blue = BAR_FG, + magenta = BAR_FG, + green = BAR_FG, + }) + end + return M +end + +return M diff --git a/lua/features/lualine/theme.lua b/lua/features/lualine/theme.lua new file mode 100644 index 0000000..74a83d3 --- /dev/null +++ b/lua/features/lualine/theme.lua @@ -0,0 +1,17 @@ +local Utils = require("utils") + +---@class LualineTheme +local M = setmetatable({}, { + __call = function(m, ...) + return m.get(...) + end, +}) + +---@param config LualineOptions +function M.get(config) + local editor_bg = Utils.theme.highlight("Normal").bg or "NONE" + local theme = config.float and { normal = { c = { bg = editor_bg } } } or "auto" + return theme +end + +return M diff --git a/lua/plugins/config/neo-tree/init.lua b/lua/features/neo-tree/init.lua old mode 100755 new mode 100644 similarity index 89% rename from lua/plugins/config/neo-tree/init.lua rename to lua/features/neo-tree/init.lua index ea5dac0..46b9a00 --- a/lua/plugins/config/neo-tree/init.lua +++ b/lua/features/neo-tree/init.lua @@ -1,9 +1,9 @@ -local Util = require("util") +local Utils = require("utils") local Icons = require("core.icons") local config = { close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab - popup_border_style = Util.generate_borderchars("thick", "tl-t-tr-r-bl-b-br-l"), + popup_border_style = Utils.telescope.borderchars("thick", "tl-t-tr-r-br-b-bl-l"), sources = { "filesystem", "buffers", @@ -20,7 +20,7 @@ local config = { { source = "filesystem", display_name = "󰉓" }, { source = "buffers", display_name = "󰈙" }, { source = "git_status", display_name = "" }, - { source = "document_symbols", display_name = "o" }, + -- { source = "document_symbols", display_name = "o" }, { source = "diagnostics", display_name = "󰒡" }, }, }, @@ -62,7 +62,7 @@ local config = { window = { mappings = { ["H"] = "navigate_up", - [""] = "toggle_hidden", + [""] = "toggle_hidden", ["."] = "set_root", ["/"] = "fuzzy_finder", ["f"] = "filter_on_submit", @@ -83,7 +83,7 @@ local config = { async_directory_scan = "always", } -config.filesystem.components = require("plugins.config.neo-tree.sources.filesystem.components") +config.filesystem.components = require("features.neo-tree.sources.filesystem.components") local function hideCursor() vim.cmd([[ setlocal guicursor=n:block-Cursor @@ -97,7 +97,7 @@ local function showCursor() ]]) end -local neotree_group = Util.augroup("neo-tree_hide_cursor") +local neotree_group = Utils.augroup("neo-tree_hide_cursor") vim.api.nvim_create_autocmd({ "FileType" }, { pattern = "neo-tree", callback = function() diff --git a/lua/plugins/config/neo-tree/sources/filesystem/components.lua b/lua/features/neo-tree/sources/filesystem/components.lua old mode 100755 new mode 100644 similarity index 96% rename from lua/plugins/config/neo-tree/sources/filesystem/components.lua rename to lua/features/neo-tree/sources/filesystem/components.lua index 819639c..04fd749 --- a/lua/plugins/config/neo-tree/sources/filesystem/components.lua +++ b/lua/features/neo-tree/sources/filesystem/components.lua @@ -1,6 +1,6 @@ local M = {} -M.name = function(config, node, state) +function M.name(config, node, state) local common = require("neo-tree.sources.common.components") local highlights = require("neo-tree.ui.highlights") @@ -42,7 +42,7 @@ M.name = function(config, node, state) } end -M.icon = function(config, node, state) +function M.icon(config, node, state) local common = require("neo-tree.sources.common.components") local highlights = require("neo-tree.ui.highlights") diff --git a/lua/init.lua b/lua/init.lua new file mode 100644 index 0000000..7df022b --- /dev/null +++ b/lua/init.lua @@ -0,0 +1,8 @@ +local M = {} + +function M.bootstrap() + require("core").setup() + require("core.lazy") +end + +return M diff --git a/lua/plugins/aisync.lua b/lua/plugins/aisync.lua new file mode 100644 index 0000000..0ec869d --- /dev/null +++ b/lua/plugins/aisync.lua @@ -0,0 +1,150 @@ +--[[ + Unleash seamless collaboration between AI and coding + Effortlessly boost efficiency with plugins that adapt to your needs, + creating a streamlined and innovative development experience. + -- Aisync -- +]] +local Utils = require("utils") + +return { + -- Copilot + { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + event = { "InsertEnter" }, + build = ":Copilot auth", + dependencies = { "zbirenbaum/copilot-cmp" }, + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + filetypes = { + ["*"] = true, -- disable for all other filetypes and ignore default `filetypes` + }, + }, + }, + { + "zbirenbaum/copilot-cmp", + event = { "InsertEnter" }, + dependencies = { "copilot.lua" }, + opts = {}, + config = function(_, opts) + local copilot_cmp = require("copilot_cmp") + copilot_cmp.setup(opts) + Utils.lsp.on_attach(function(client, _) + if client.name == "copilot" then + copilot_cmp._on_insert_enter() + end + end) + end, + }, + + -- Codeium + { + "Exafunction/codeium.nvim", + event = { "InsertEnter" }, + build = ":Codeium Auth", + opts = { + enable_chat = true, + }, + }, + + { + "huggingface/llm.nvim", + -- event = { "InsertEnter", "CmdlineEnter" }, + lazy = true, + opts = function() + local job = require("plenary.job") + local logger = require("plenary.log").new({ + plugin = "llm.nvim", + level = "info", + }) + + local splitCommandIntoTable = function(command) + local cmd = {} + for word in command:gmatch("%S+") do + table.insert(cmd, word) + end + return cmd + end + + local function loadConfigFromCommand(command, callback, defaultValue) + local cmd = splitCommandIntoTable(command) + job + :new({ + command = cmd[1], + args = vim.list_slice(cmd, 2, #cmd), + on_exit = function(j, exit_code) + if exit_code ~= 0 then + logger.warn("Command'" .. command .. "' did not return a value when executed") + return + end + local value = j:result()[1]:gsub("%s+$", "") + if value ~= nil and value ~= "" then + callback(value) + elseif defaultValue ~= nil and defaultValue ~= "" then + callback(defaultValue) + end + end, + }) + :start() + end + + local huggingface_api_token + local command = "pass show huggingface/access-token" + loadConfigFromCommand(command, function(value) + huggingface_api_token = value + end, "") + + return { + api_token = huggingface_api_token, + model = "bigcode/starcoder", -- can be a model ID or an http(s) endpoint + accept_keymap = "", + dismiss_keymap = "", + query_params = { + max_new_tokens = 60, + temperature = 0.3, + top_p = 0.95, + stop_tokens = nil, + }, + enable_suggestions_on_files = "*.py,*.lua,*.java,*.js,*.jsx,*.ts,*.tsx,*.html,*.css,*.scss,*.json,*.yaml,*.yml,*.md,*.rmd,*.tex,*.bib,*.cpp,*.h,*.hpp", -- pattern matching syntax to enable suggestions on specific files, either a string or a list of strings + } + end, + }, + + { + "jackMort/ChatGPT.nvim", + cmd = { "ChatGPTActAs", "ChatGPT" }, + opts = { + api_key_cmd = "pass show OpenAI/Rockship", + openai_edit_params = { + model = "gpt-4-1106-preview", + -- model = "gpt-4", + frequency_penalty = 0, + presence_penalty = 0, + temperature = 0.9, + top_p = 1, + n = 1, + }, + }, + keys = { + { "cc", "ChatGPT", desc = "ChatGPT" }, + { "ce", "ChatGPTEditWithInstruction", desc = "Edit with instruction", mode = { "n", "v" } }, + { "cg", "ChatGPTRun grammar_correction", desc = "Grammar Correction", mode = { "n", "v" } }, + { "ct", "ChatGPTRun translate", desc = "Translate", mode = { "n", "v" } }, + { "ck", "ChatGPTRun keywords", desc = "Keywords", mode = { "n", "v" } }, + { "cd", "ChatGPTRun docstring", desc = "Docstring", mode = { "n", "v" } }, + { "ca", "ChatGPTRun add_tests", desc = "Add Tests", mode = { "n", "v" } }, + { "co", "ChatGPTRun optimize_code", desc = "Optimize Code", mode = { "n", "v" } }, + { "cs", "ChatGPTRun summarize", desc = "Summarize", mode = { "n", "v" } }, + { "cf", "ChatGPTRun fix_bugs", desc = "Fix Bugs", mode = { "n", "v" } }, + { "cx", "ChatGPTRun explain_code", desc = "Explain Code", mode = { "n", "v" } }, + { "cr", "ChatGPTRun roxygen_edit", desc = "Roxygen Edit", mode = { "n", "v" } }, + { + "cl", + "ChatGPTRun code_readability_analysis", + desc = "Code Readability Analysis", + mode = { "n", "v" }, + }, + }, + }, +} diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua old mode 100755 new mode 100644 index 10ee717..1f95180 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -1,20 +1,7 @@ --- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ --- ╏ ╏ --- ╏ Coding Resources ╏ --- ╏ ╏ --- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ +local Utils = require("utils") +local Icons = require("core").icons return { - { - "huggingface/llm.nvim", - lazy = true, - opts = { - model = "bigcode/starcoder", -- can be a model ID or an http(s) endpoint - accept_keymap = "", - dismiss_keymap = "", - }, - }, - --╞═══════════════════════════════════════════════════════════════╡ { "L3MON4D3/LuaSnip", dependencies = { @@ -86,239 +73,157 @@ return { end) end, }, - -- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ + { "rafamadriz/friendly-snippets", config = function() require("luasnip.loaders.from_vscode").lazy_load() end, }, - - -- ╞═══════════════════════════════════════════════════════════════╡ - { - "mattn/emmet-vim", - event = { "BufRead", "BufNewFile" }, - init = function() - vim.g.user_emmet_leader_key = "f" - vim.g.user_emmet_mode = "n" - vim.g.user_emmet_settings = { - variables = { lang = "ja" }, - javascript = { - extends = "jsx", - }, - html = { - default_attributes = { - option = { value = vim.null }, - textarea = { - id = vim.null, - name = vim.null, - cols = 10, - rows = 10, - }, - }, - snippets = { - ["!"] = "\n" - .. '\n' - .. "\n" - .. '\t\n' - .. '\t\n' - .. '\t\n' - .. "\t\n" - .. "\n" - .. "\n\t${child}|\n\n" - .. "", - }, - }, - } - end, - }, - -- ╞═══════════════════════════════════════════════════════════════╡ - { - "zbirenbaum/copilot.lua", - cmd = "Copilot", - build = ":Copilot auth", - opts = { - suggestion = { enabled = true }, - panel = { enabled = true }, - filetypes = { - markdown = true, - help = true, - }, - }, - }, - - -- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ + -- ───────────────────────────────────────────────────────────────── { "hrsh7th/nvim-cmp", + version = false, + event = { "InsertEnter", "CmdlineEnter" }, dependencies = { - "David-Kunz/cmp-npm", - "L3MON4D3/LuaSnip", - "L3MON4D3/cmp-luasnip-choice", - "davidsierradz/cmp-conventionalcommits", - "dmitmel/cmp-cmdline-history", - "doxnit/cmp-luasnip-choice", - "garyhurtz/cmp_kitty", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-calc", - "hrsh7th/cmp-cmdline", + "mfussenegger/nvim-jdtls", "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lsp-document-symbol", - "hrsh7th/cmp-nvim-lsp-signature-help", - "hrsh7th/cmp-nvim-lsp-signature-help", + "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", - "mfussenegger/nvim-jdtls", - "petertriho/cmp-git", - "ray-x/cmp-treesitter", + "hrsh7th/cmp-cmdline", "saadparwaiz1/cmp_luasnip", - "tamago324/cmp-zsh", - "onsails/lspkind-nvim", - { - "Saecki/crates.nvim", - event = { "BufRead Cargo.toml" }, - opts = {}, - }, - { - "Exafunction/codeium.nvim", - cmd = "Codeium", - build = ":Codeium Auth", - opts = {}, - }, - { - "zbirenbaum/copilot-cmp", - dependencies = "copilot.lua", - opts = {}, - config = function(_, opts) - local copilot_cmp = require("copilot_cmp") - copilot_cmp.setup(opts) - -- attach cmp source whenever copilot attaches - -- fixes lazy-loading issues with the copilot cmp source - require("util").on_attach(function(client) - if client.name == "copilot" then - copilot_cmp._on_insert_enter({}) - end - end) - end, - }, + "hrsh7th/cmp-nvim-lsp", }, - config = function() + opts = function() local cmp = require("cmp") - local lspkind = require("lspkind") + local defaults = require("cmp.config.default")() + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") - cmp.setup({ - formatting = { - format = lspkind.cmp_format({ - with_text = false, - maxwidth = 50, - mode = "symbol", - menu = { - buffer = "BUF", - rg = "RG", - nvim_lsp = "LSP", - path = "PATH", - luasnip = "SNIP", - calc = "CALC", - }, - }), - }, + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { { name = "buffer" } }, + }) + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline" } }), + }) + cmp.setup.filetype("java", { completion = { keyword_length = 2 } }) + return { + window = vim.tbl_contains(monokai_opts.background_clear or {}, "float_win") and { + completion = cmp.config.window.bordered({ border = "rounded" }), + documentation = cmp.config.window.bordered({ border = "rounded" }), + } or nil, + completion = { completeopt = "menu,menuone,noinsert" }, snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() - end - end, { "i", "s" }), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + -- [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + -- [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping(function(fallback) + require("luasnip").unlink_current() + fallback() + end), }), sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "nvim_lua" }, + { name = "codeium" }, + { name = "copilot" }, + { name = "nvim_lsp", keyword_length = 2 }, { name = "luasnip" }, - { name = "buffer" }, + { name = "buffer", keyword_length = 3 }, { name = "path" }, - { name = "calc" }, - { name = "crates" }, - { name = "treesitter" }, - { name = "cmdline" }, - { name = "cmdline-history" }, - { name = "zsh" }, - { - name = "copilot", - group_index = 1, - priority = 100, - }, - { - name = "dictionary", - keyword_length = 2, - }, - { name = "luasnip-choice" }, - { - name = "codeium", - group_index = 1, - priority = 100, - }, - { name = "nvim_lsp_signature_help" }, - { name = "nvim_lsp" }, - - { name = "luasnip" }, - { name = "calc" }, - { name = "path" }, - { name = "buffer", keyword_length = 5 }, - { name = "treesitter" }, - { name = "cmdline" }, - { name = "cmdline-history" }, - { name = "zsh" }, - { name = "crates" }, }), - }) - - -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, item) + item.menu = ({ + codeium = "Codeium", + copilot = "Copilot", + nvim_lsp = item.kind, + luasnip = "Snippet", + buffer = "Buffer", + path = "Path", + })[entry.source.name] + if Icons.kinds[item.kind] then + item.kind = Icons.kinds[item.kind] + end + local brain_kind = Icons.brain[entry.source.name] + if brain_kind then + local hl_gr = Utils.string.capitalize("CmpItemKind" .. Utils.string.capitalize(entry.source.name)) + item.kind = brain_kind + item.kind_hl_group = hl_gr + vim.api.nvim_set_hl(0, hl_gr, { fg = Icons.colors.brain[entry.source.name] }) + end + return item + end, + }, + experimental = { ghost_text = true }, + sorting = defaults.sorting, + } + end, + }, + { + "LudoPinelli/comment-box.nvim", + config = function() + require("comment-box").setup({ + doc_width = 80, -- width of the document + box_width = 65, -- width of the boxes + borders = { -- symbols used to draw a box + top = "─", + bottom = "─", + left = "│", + right = "│", + top_left = "╭", + top_right = "╮", + bottom_left = "╰", + bottom_right = "╯", + }, + line_width = 65, -- width of the lines + line = { -- symbols used to draw a line + line = "─", + line_start = "─", + line_end = "─", }, + outer_blank_lines = true, -- insert a blank line above and below the box + inner_blank_lines = true, -- insert a blank line above and below the text + line_blank_line_above = false, -- insert a blank line above the line + line_blank_line_below = false, -- insert a blank line below the line }) + end, + }, + -- ───────────────────────────────────────────────────────────────── + { + "numToStr/Comment.nvim", + dependencies = "JoosepAlviste/nvim-ts-context-commentstring", + config = function() + local status_ok, comment = pcall(require, "Comment") + if not status_ok then + vim.notify("Comment not found!") + return + end - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), + comment.setup({ + pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), }) end, }, - -- ╞═══════════════════════════════════════════════════════════════╡ + -- ───────────────────────────────────────────────────────────────── { "echasnovski/mini.pairs", event = "VeryLazy", - config = function(_, opts) - require("mini.pairs").setup(opts) - end, + opts = {}, }, - -- ╞═══════════════════════════════════════════════════════════════╡ - -- comments + -- ───────────────────────────────────────────────────────────────── { "JoosepAlviste/nvim-ts-context-commentstring", lazy = true }, { "echasnovski/mini.comment", @@ -331,7 +236,7 @@ return { }, }, }, - -- ╞═══════════════════════════════════════════════════════════════╡ + -- ───────────────────────────────────────────────────────────────── { "ray-x/lsp_signature.nvim", event = { "InsertEnter" }, @@ -341,7 +246,6 @@ return { hint_scheme = "Comment", -- highlight group for the virtual text }, }, - -- ╞═══════════════════════════════════════════════════════════════╡ { "LudoPinelli/comment-box.nvim", config = function() @@ -387,29 +291,19 @@ return { }) end, }, - --╞═══════════════════════════════════════════════════════════════╡ - { - "glepnir/lspsaga.nvim", - lazy = true, - config = function() - require("lspsaga").setup({}) - end, - }, - --╞═══════════════════════════════════════════════════════════════╡ - -- Highlight, list and search todo comments in your projects { "folke/todo-comments.nvim", event = { "BufRead", "BufEnter" }, dependencies = "nvim-telescope/telescope.nvim", - -- stylua: ignore - keys = { - { ']t', function() require('todo-comments').jump_next() end, desc = 'Next todo comment' }, - { '[t', function() require('todo-comments').jump_prev() end, desc = 'Previous todo comment' }, - { 'Tt', 'TodoTrouble', desc = 'Todo (Trouble)' }, - { 'TT', 'TodoTrouble keywords=TODO,FIX,FIXME', desc = 'Todo/Fix/Fixme (Trouble)' }, - { 'Tt', 'TodoTelescope', desc = 'Todo' }, - { 'TT', 'TodoTelescope keywords=TODO,FIX,FIXME', desc = 'Todo/Fix/Fixme' }, - }, + -- stylua: ignore + keys = { + { ']t', function() require('todo-comments').jump_next() end, desc = 'Next todo comment' }, + { '[t', function() require('todo-comments').jump_prev() end, desc = 'Previous todo comment' }, + { 'Tt', 'TodoTrouble', desc = 'Todo (Trouble)' }, + { 'TT', 'TodoTrouble keywords=TODO,FIX,FIXME', desc = 'Todo/Fix/Fixme (Trouble)' }, + { 'Tt', 'TodoTelescope', desc = 'Todo' }, + { 'TT', 'TodoTelescope keywords=TODO,FIX,FIXME', desc = 'Todo/Fix/Fixme' }, + }, opts = { signs = false }, }, @@ -443,13 +337,13 @@ return { end, opts = { mappings = { - add = "gsa", -- Add surrounding in Normal and Visual modes - delete = "gsd", -- Delete surrounding - find = "gsf", -- Find surrounding (to the right) - find_left = "gsF", -- Find surrounding (to the left) - highlight = "gsh", -- Highlight surrounding - replace = "gsr", -- Replace surrounding - update_n_lines = "gsn", -- Update `n_lines` + add = "Ga", -- Add surrounding in Normal and Visual modes + delete = "Gd", -- Delete surrounding + find = "Gf", -- Find surrounding (to the right) + find_left = "GF", -- Find surrounding (to the left) + highlight = "Gh", -- Highlight surrounding + replace = "Gr", -- Replace surrounding + update_n_lines = "Gn", -- Update `n_lines` }, }, }, diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua old mode 100755 new mode 100644 index 2067f6d..52d4b02 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,55 +1,82 @@ --- disable git detecting changes --- git update-index --skip-worktree lua/tvl/core/resources/colorscheme.lua - --- enable git detecting changes --- git update-index --no-skip-worktree lua/tvl/core/resources/colorscheme.lua return { { "loctvl842/monokai-pro.nvim", lazy = false, priority = 1000, - keys = { { "c", "MonokaiProSelect", desc = "Select Moonokai pro filter" } }, - config = function() - local monokai = require("monokai-pro") - monokai.setup({ - transparent_background = false, - devicons = true, - filter = "spectrum", -- classic | octagon | pro | machine | ristretto | spectrum - day_night = { - enable = false, - day_filter = "pro", - night_filter = "spectrum", + keys = { { "uc", "MonokaiProSelect", desc = "Select Moonokai pro filter" } }, + opts = { + transparent_background = false, + devicons = true, + filter = "spectrum", -- classic | octagon | pro | machine | ristretto | spectrum + day_night = { + enable = false, + day_filter = "pro", + night_filter = "spectrum", + }, + inc_search = "background", -- underline | background + background_clear = { + "nvim-tree", + "neo-tree", + "bufferline", + -- "telescope", + "toggleterm", + }, + plugins = { + bufferline = { + underline_selected = true, + underline_visible = true, + underline_fill = true, + bold = true, }, - inc_search = "background", -- underline | background - background_clear = { "nvim-tree", "neo-tree", "bufferline" }, - plugins = { - bufferline = { - underline_selected = true, - underline_visible = false, - underline_fill = true, - bold = false, - }, - indent_blankline = { - context_highlight = "pro", -- default | pro - context_start_underline = true, - }, + indent_blankline = { + context_highlight = "pro", -- default | pro + context_start_underline = true, }, - override = function(c) - return { - ColorColumn = { bg = c.editor.background }, - -- Mine - DashboardRecent = { fg = c.base.magenta }, - DashboardProject = { fg = c.base.blue }, - DashboardConfiguration = { fg = c.base.white }, - DashboardSession = { fg = c.base.green }, - DashboardLazy = { fg = c.base.cyan }, - DashboardServer = { fg = c.base.yellow }, - DashboardQuit = { fg = c.base.red }, - -- Codeium Icon - CmpItemKindVariable = { fg = "#09B6A2" }, - } - end, - }) + }, + override = function(c) + return { + ColorColumn = { bg = c.editor.background }, + -- Mine + DashboardRecent = { fg = c.base.magenta }, + DashboardProject = { fg = c.base.blue }, + DashboardConfiguration = { fg = c.base.white }, + DashboardSession = { fg = c.base.green }, + DashboardLazy = { fg = c.base.cyan }, + DashboardServer = { fg = c.base.yellow }, + DashboardQuit = { fg = c.base.red }, + IndentBlanklineChar = { fg = c.base.dimmed4 }, + -- mini.hipatterns + MiniHipatternsFixme = { fg = c.base.black, bg = c.base.red, bold = true }, -- FIXME + MiniHipatternsTodo = { fg = c.base.black, bg = c.base.blue, bold = true }, -- TODO + MiniHipatternsHack = { fg = c.base.black, bg = c.base.yellow, bold = true }, -- HACK + MiniHipatternsNote = { fg = c.base.black, bg = c.base.green, bold = true }, -- NOTE + } + end, + overridePalette = function(filter) + -- if filter == "pro" then + -- return { + -- dark2 = "#101014", + -- dark1 = "#16161E", + -- background = "#1A1B26", + -- text = "#C0CAF5", + -- accent1 = "#f7768e", + -- accent2 = "#7aa2f7", + -- accent3 = "#e0af68", + -- accent4 = "#9ece6a", + -- accent5 = "#0DB9D7", + -- accent6 = "#9d7cd8", + -- dimmed1 = "#737aa2", + -- dimmed2 = "#787c99", + -- dimmed3 = "#363b54", + -- dimmed4 = "#363b54", + -- dimmed5 = "#16161e", + -- } + -- end + end, + }, + config = function(_, opts) + local monokai = require("monokai-pro") + monokai.setup(opts) monokai.load() end, }, diff --git a/lua/plugins/config/cmp/dict.lua b/lua/plugins/config/cmp/dict.lua deleted file mode 100755 index 1e9399d..0000000 --- a/lua/plugins/config/cmp/dict.lua +++ /dev/null @@ -1,23 +0,0 @@ -local M = {} -local dict = require("cmp_dictionary") - -dict.setup({ - -- The following are default values. - exact = 2, - first_case_insensitive = false, - document = false, - document_command = "wn %s -over", - sqlite = false, - max_items = -1, - capacity = 5, - debug = false, -}) - -dict.switcher({ - spelllang = { - en = "/home/tlh/.config/nvim/spell/en.dict", - hi = "/home/tlh/.config/nvim/spell/hi.dict", - es = "/home/tlh/.config/nvim/spell/es.dict", - }, -}) -return M diff --git a/lua/plugins/config/compile.lua b/lua/plugins/config/compile.lua deleted file mode 100755 index 806bffa..0000000 --- a/lua/plugins/config/compile.lua +++ /dev/null @@ -1,40 +0,0 @@ -local status_ok, compile = pcall(require, "compile-nvim") -if not status_ok then - return -end - -compile.setup({ - cmds = { - typescript = "node %", - javascript = "node %", - markdown = "glow %", - python = "python %", - rust = "rustc % && ./$fileBase && rm $fileBase", - -- rust = "cargo run", - cpp = "g++ -O2 -Wall % -o $fileBase && ./$fileBase", - go = "go run %", - sh = "sh %", - lua = "lua %", - }, - -- UI settings - ui = { - -- Auto-save the current file - -- before executing it - autosave = true, - -- Floating Window / FTerm settings - -- Floating window border (see ':h nvim_open_win') - border = "rounded", - -- Num from `0 - 1` for measurements - height = 0.5, - width = 0.5, - x = 0.96, - y = 0.02, - -- Highlight group for floating window/border (see ':h winhl') - --border - border_hl = "TermBorder", - -- background - normal_hl = "Normal", - -- Floating Window Transparency (see ':h winblend') - blend = 30, - }, -}) diff --git a/lua/plugins/config/dashboard.lua b/lua/plugins/config/dashboard.lua deleted file mode 100755 index 4caac86..0000000 --- a/lua/plugins/config/dashboard.lua +++ /dev/null @@ -1,87 +0,0 @@ -local dashboard = require("dashboard") -local Logo = require("core.logo") - -if vim.o.filetype == "lazy" then - vim.cmd.close() -end - -vim.api.nvim_create_autocmd("User", { - pattern = "LazyVimStarted", - callback = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - dashboard.setup({ - theme = "doom", - hide = { - statusline = 0, - tabline = 0, - winbar = 0, - }, - shortcut = { - { desc = "󰚰 Update", group = "@property", action = "Lazy update", key = "u" }, - }, - config = { - header = Logo.logos.random(), - center = { - { - icon = " ", - icon_hl = "DashboardRecent", - desc = "Recent Files ", - -- desc_hi = "String", - key = "r", - key_hl = "DashboardRecent", - action = "Telescope oldfiles", - }, - { - icon = " ", - icon_hl = "DashboardSession", - desc = "Last Session", - -- desc_hi = "String", - key = "s", - key_hl = "DashboardSession", - action = "lua require('persistence').load({last = true})", - }, - { - icon = " ", - icon_hl = "DashboardConfiguration", - desc = "Configuration", - -- desc_hi = "String", - key = "i", - key_hl = "DashboardConfiguration", - action = "edit $MYVIMRC", - }, - { - icon = "󰤄 ", - icon_hl = "DashboardLazy", - desc = "Lazy", - -- desc_hi = "String", - key = "l", - key_hl = "DashboardLazy", - action = "Lazy", - }, - { - icon = " ", - icon_hl = "DashboardServer", - desc = "Mason", - -- desc_hi = "String", - key = "m", - key_hl = "DashboardServer", - action = "Mason", - }, - { - icon = " ", - icon_hl = "DashboardQuit", - desc = "Quit Neovim", - -- desc_hi = "String", - key = "q", - key_hl = "DashboardQuit", - action = "qa", - }, - }, - footer = { - "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms", - }, --your footer - }, - }) - end, -}) diff --git a/lua/plugins/config/hydra/hydra.lua b/lua/plugins/config/hydra/hydra.lua deleted file mode 100755 index a966048..0000000 --- a/lua/plugins/config/hydra/hydra.lua +++ /dev/null @@ -1,3 +0,0 @@ -require('plugins.config.hydra.spelling') -require('plugins.config.hydra.telescope') -require('plugins.config.hydra.windows') diff --git a/lua/plugins/config/hydra/spelling.lua b/lua/plugins/config/hydra/spelling.lua deleted file mode 100755 index a5c435c..0000000 --- a/lua/plugins/config/hydra/spelling.lua +++ /dev/null @@ -1,37 +0,0 @@ -local Hydra = require("hydra") - -local function cmd(command) - return table.concat({ "", command, "" }) -end - -local hint = [[ - _J_: next _K_: previous - _a_: add word _l_: list corrections - _f_: use first correction - - ^ - _q_: Exit -]] - -Hydra({ - name = "Spelling", - hint = hint, - config = { - invoke_on_body = true, - hint = { - position = "bottom", - border = "rounded", - }, - }, - mode = "n", - body = "Hz", - heads = { - { "J", "]s" }, - { "K", "[s" }, - { "a", "zg" }, - { "l", cmd("Telescope spell_suggest") }, - { "f", "1z=" }, - { "q", nil, { exit = true, nowait = true } }, - }, -}) - diff --git a/lua/plugins/config/hydra/telescope.lua b/lua/plugins/config/hydra/telescope.lua deleted file mode 100755 index da5ca77..0000000 --- a/lua/plugins/config/hydra/telescope.lua +++ /dev/null @@ -1,79 +0,0 @@ -local Hydra = require("hydra") - -local function cmd(command) - return table.concat({ "", command, "" }) -end - -local hint = [[ - _f_: files _p_: projects - _t_: live grep _s_: grep string - _H_: header _S_: symbols - _R_: register _P_: plugins - _h_: vim help _c_: execute command - _k_: keymaps _;_: commands history - _O_: options _?_: search history - _/_: search in file _m_: make - _r_: recently opened files - - ^ - __: Telescope _q_: Exit -]] - -Hydra({ - name = "Telescope", - hint = hint, - config = { - invoke_on_body = true, - hint = { - position = "middle", - border = "rounded", - }, - }, - mode = "n", - body = "Hs", - heads = { - { "c", cmd("Telescope commands"), { desc = "execute command" } }, - { "f", cmd("Telescope find_files"), { desc = "Find a File" } }, - { "t", cmd("Telescope live_grep"), { desc = "Fuzzy Grep Search" } }, - { "h", cmd("Telescope help_tags"), { desc = "vim help" } }, - { - "H", - cmd("Telescope heading"), - { desc = "Choose a heading in the file" }, - }, - { "k", cmd("Telescope keymaps"), { desc = "Search Keymaps" } }, - { "O", cmd("Telescope vim_options"), { desc = "Vim Options Search" } }, - { "m", cmd("Telescope make"), { desc = "Make Search" } }, - { "p", cmd("Telescope projects"), { desc = "projects" } }, - { - "r", - cmd("Telescope oldfiles"), - { desc = "recently opened files" }, - }, - { "R", cmd("Telescope registers"), { desc = "Search Registers" } }, - { "s", cmd("Telescope grep_string"), { desc = "Text under cursor" } }, - { "S", cmd("Telescope symbols"), { desc = "Search Symbols" } }, - { - "/", - cmd("Telescope current_buffer_fuzzy_find"), - { desc = "search in file" }, - }, - { "?", cmd("Telescope search_history"), { desc = "search history" } }, - { - ";", - cmd("Telescope command_history"), - { desc = "command-line history" }, - }, - { - "", - cmd("Telescope"), - { exit = true, desc = "list all pickers" }, - }, - { - "q", - nil, - { exit = true, nowait = true }, - }, - }, -}) - diff --git a/lua/plugins/config/hydra/windows.lua b/lua/plugins/config/hydra/windows.lua deleted file mode 100755 index a91380d..0000000 --- a/lua/plugins/config/hydra/windows.lua +++ /dev/null @@ -1,65 +0,0 @@ -local Hydra = require("hydra") -local picker = require("window-picker") - -local function cmd(command) - return table.concat({ "", command, "" }) -end - -local hint = [[ - Move Size Splits - ----- ------ --------- - ^ ^ _K_ ^ ^ ^ ^ _k_ ^ ^ _s_: horizontally - _H_ ^ ^ _L_ _h_ ^ ^ _l_ _v_: vertically - ^ ^ _J_ ^ ^ ^ ^ _j_ ^ ^ _c_: close - - _=_: equalize _m_: toggle maximize - _p_: pick - _r_: Rotate down/right _R_: rotate up/left - ^ - _q_: exit -]] - -local pick_window = function() - local picked_window_id = picker.pick_window() or vim.api.nvim_get_current_win() - vim.api.nvim_set_current_win(picked_window_id) -end - -local opts = { exit = true, nowait = true } - -Hydra({ - name = "Windows", - hint = hint, - config = { - color = "red", - invoke_on_body = true, - hint = { - position = "middle", - border = "rounded", - }, - }, - mode = "n", - body = "ww", - heads = { - { "s", cmd("split"), opts }, - { "v", cmd("vsplit"), opts }, - { "c", cmd("close"), opts }, -- close current window - { "m", cmd("WindowsMaximize"), opts }, -- maximize current window - -- window resizing - { "=", cmd("wincmd =") }, - { "k", cmd("wincmd +") }, - { "j", cmd("wincmd -") }, - { "h", cmd("wincmd <") }, - { "l", cmd("wincmd >") }, - -- move window around - { "H", cmd("wincmd H") }, - { "J", cmd("wincmd J") }, - { "K", cmd("wincmd K") }, - { "L", cmd("wincmd L") }, - -- rotate window - { "r", cmd("wincmd r") }, - { "R", cmd("wincmd R") }, - -- pick window - { "p", pick_window, opts }, - { "q", nil, opts }, - }, -}) diff --git a/lua/plugins/config/lsp/diagnostics.lua b/lua/plugins/config/lsp/diagnostics.lua deleted file mode 100755 index 8871849..0000000 --- a/lua/plugins/config/lsp/diagnostics.lua +++ /dev/null @@ -1,53 +0,0 @@ -local Util = require("util") -vim.g.diagnostics_enabled = true - -local function get_diagnostics() - for name, icon in pairs(require("core.icons").diagnostics) do - local function firstUpper(s) - return s:sub(1, 1):upper() .. s:sub(2) - end - name = "DiagnosticSign" .. firstUpper(name) - vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) - end - return { - off = { - underline = true, - virtual_text = false, - signs = false, - update_in_insert = false, - }, - on = { - virtual_text = { - spacing = 4, - source = "if_many", - prefix = "●", - }, -- disable virtual text - virtual_lines = false, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = false, - style = "minimal", - -- border = "rounded", - border = Util.generate_borderchars("thick", "tl-t-tr-r-bl-b-br-l"), - source = "always", - header = "", - prefix = "", - }, - }, - } -end -local diagnostics = get_diagnostics() - -vim.api.nvim_create_user_command("ToggleDiagnostic", function() - if vim.g.diagnostics_enabled then - vim.diagnostic.config(diagnostics["off"]) - vim.g.diagnostics_enabled = false - else - vim.diagnostic.config(diagnostics["on"]) - vim.g.diagnostics_enabled = true - end -end, { nargs = 0 }) - -return diagnostics diff --git a/lua/plugins/config/lsp/gitsigns.lua b/lua/plugins/config/lsp/gitsigns.lua deleted file mode 100755 index 1ce046b..0000000 --- a/lua/plugins/config/lsp/gitsigns.lua +++ /dev/null @@ -1,33 +0,0 @@ -local M = {} - -M.attach = function(_, buffer) - local gs = package.loaded.gitsigns - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = buffer - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map("n", "]c", function() - if vim.wo.diff then - return "]c" - end - vim.schedule(function() - gs.next_hunk() - end) - return "" - end, { expr = true }) - - map("n", "[c", function() - if vim.wo.diff then - return "[c" - end - vim.schedule(function() - gs.prev_hunk() - end) - return "" - end, { expr = true }) -end - -return M diff --git a/lua/plugins/config/lualine/components.lua b/lua/plugins/config/lualine/components.lua deleted file mode 100755 index 8150641..0000000 --- a/lua/plugins/config/lualine/components.lua +++ /dev/null @@ -1,167 +0,0 @@ -local config = require("plugins.config.lualine.config").options -local icons = require("core.icons") - -local M = {} - -local hl_str = function(str, hl_cur, hl_after) - if hl_after == nil then - return "%#" .. hl_cur .. "#" .. str .. "%*" - end - return "%#" .. hl_cur .. "#" .. str .. "%*" .. "%#" .. hl_after .. "#" -end - -local function hide_in_width() - return vim.fn.winwidth(0) > 85 -end - -local function truncate(text, min_width) - if string.len(text) > min_width then - return string.sub(text, 1, min_width) .. "…" - end - return text -end - -local prev_branch = "" -M.branch = { - "branch", - icons_enabled = true, - icon = hl_str("", "SLGitIcon", "SLBranchName"), - colored = false, - fmt = function(str) - if vim.bo.filetype == "toggleterm" then - str = prev_branch - elseif str == "" or str == nil then - str = "!=vcs" - end - prev_branch = str - local icon = hl_str(" ", "SLGitIcon", "SLBranchName") - return hl_str(config.separator_icon.left, "SLSeparator") - .. hl_str(icon, "SLGitIcon") - .. hl_str(truncate(str, 10), "SLBranchName") - .. hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") - end, -} - -M.position = function() - -- print(vim.inspect(config.separator_icon)) - local current_line = vim.fn.line(".") - local current_column = vim.fn.col(".") - local left_sep = hl_str(config.separator_icon.left, "SLSeparator") - local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") - local str = "Ln " .. current_line .. ", Col " .. current_column - return left_sep .. hl_str(str, "SLPosition", "SLPosition") .. right_sep -end - -M.spaces = function() - local left_sep = hl_str(config.separator_icon.left, "SLSeparator") - local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") - local str = "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") - return left_sep .. hl_str(str, "SLShiftWidth", "SLShiftWidth") .. right_sep -end - -M.diagnostics = function() - local function nvim_diagnostic() - local diagnostics = vim.diagnostic.get(0) - local count = { 0, 0, 0, 0 } - for _, diagnostic in ipairs(diagnostics) do - count[diagnostic.severity] = count[diagnostic.severity] + 1 - end - return count[vim.diagnostic.severity.ERROR], - count[vim.diagnostic.severity.WARN], - count[vim.diagnostic.severity.INFO], - count[vim.diagnostic.severity.HINT] - end - - local error_count, warn_count, info_count, hint_count = nvim_diagnostic() - local error_hl = hl_str(icons.diagnostics.error .. " " .. error_count, "SLError", "SLError") - local warn_hl = hl_str(icons.diagnostics.warn .. " " .. warn_count, "SLWarning", "SLWarning") - local info_hl = hl_str(icons.diagnostics.info .. " " .. info_count, "SLInfo", "SLInfo") - local hint_hl = hl_str(icons.diagnostics.hint .. " " .. hint_count, "SLInfo", "SLInfo") - local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator") - local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator") - return left_sep .. error_hl .. " " .. warn_hl .. " " .. hint_hl .. right_sep -end - -M.diff = { - "diff", - colored = true, - diff_color = { - added = "SLDiffAdd", - modified = "SLDiffChange", - removed = "SLDiffDelete", - }, - symbols = { - added = icons.git.added .. " ", - modified = icons.git.modified .. " ", - removed = icons.git.removed .. " ", - }, -- changes diff symbols - fmt = function(str) - if str == "" then - return "" - end - local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator") - local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator") - return left_sep .. str .. right_sep - end, - cond = hide_in_width, -} - -M.mode = { - "mode", - fmt = function(str) - local left_sep = hl_str(config.separator_icon.left, "SLSeparator", "SLPadding") - local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLPadding") - return left_sep .. hl_str(str, "SLMode") .. right_sep - end, -} - -local prev_filetype = "" -M.filetype = { - "filetype", - icons_enabled = false, - icons_only = false, - fmt = function(str) - local ui_filetypes = { - "help", - "packer", - "neogitstatus", - "NvimTree", - "Trouble", - "lir", - "Outline", - "spectre_panel", - "toggleterm", - "DressingSelect", - "neo-tree", - "", - } - local filetype_str = "" - - if str == "toggleterm" then - --  - filetype_str = "ToggleTerm " .. vim.api.nvim_buf_get_var(0, "toggle_number") - elseif str == "TelescopePrompt" then - filetype_str = "" - elseif str == "neo-tree" or str == "neo-tree-popup" then - if prev_filetype == "" then - return - end - filetype_str = prev_filetype - elseif str == "help" then - filetype_str = "󰋖" - elseif vim.tbl_contains(ui_filetypes, str) then - return - else - prev_filetype = str - filetype_str = str - end - local left_sep = hl_str(config.separator_icon.left, "SLSeparator") - local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") - -- Upper case first character - filetype_str = filetype_str:gsub("%a", string.upper, 1) - local filetype_hl = hl_str(filetype_str, "SLFiletype", "SLFiletype") - return left_sep .. filetype_hl .. right_sep - end, -} - -return M diff --git a/lua/plugins/config/lualine/config.lua b/lua/plugins/config/lualine/config.lua deleted file mode 100755 index 1532d1c..0000000 --- a/lua/plugins/config/lualine/config.lua +++ /dev/null @@ -1,40 +0,0 @@ -local M = {} - ----@class LualineConfig -local default = { - float = true, - separator = "triangle", -- bubble | triangle - ---@type any - colorful = true, - --separator_icon = { left = "", right = " " }, - --thin_separator_icon = { left = "", right = " " }, - separator_icon = { left = "█", right = "█" }, - thin_separator_icon = { left = " ", right = " " }, -} - ----@type LualineConfig -M.options = {} - ----@param type "bubble" | "triangle" -local function make_separator(type) - if type == "bubble" then - M.options.separator_icon = { left = "█", right = "█" } - M.options.thin_separator_icon = { left = " ", right = " " } - elseif type == "triangle" then - M.options.separator_icon = { left = "█", right = "█" } - M.options.thin_separator_icon = { left = " ", right = " " } - else - return - end -end - -M.setup = function(opts) - M.options = vim.tbl_deep_extend("force", {}, default, opts or {}) - if M.options.float then - make_separator(M.options.separator) - end -end - -M.setup() - -return M diff --git a/lua/plugins/config/lualine/highlights.lua b/lua/plugins/config/lualine/highlights.lua deleted file mode 100755 index 21b2e13..0000000 --- a/lua/plugins/config/lualine/highlights.lua +++ /dev/null @@ -1,111 +0,0 @@ -local M = {} -local util = require("util") - -local function draw(groups) - if groups == nil then - return - end - for group, value in pairs(groups) do - vim.api.nvim_set_hl(0, group, value) - end -end - -local function generate(config, palette) - local float = config.float - local colorful = config.colorful - if colorful then - palette.yellow = util.get_highlight_value("String").foreground or "#ffff00" - palette.white = util.get_highlight_value("Normal").foreground or "#ffffff" - palette.red = util.get_highlight_value("DiagnosticError").foreground or "#ff0000" - palette.orange = util.get_highlight_value("DiagnosticWarn").foreground or "#ff7700" - palette.blue = util.get_highlight_value("DiagnosticHint").foreground or "#00ffff" - palette.magenta = util.get_highlight_value("Statement").foreground or "#ff00ff" - palette.green = util.get_highlight_value("healthSuccess").foreground or "#00ff00" - end - return { - SLGitIcon = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.white or palette.statusbar_fg, - }, - SLBranchName = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.green or palette.statusbar_fg, - }, - SLError = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = colorful and palette.red or palette.statusbar_fg, - }, - SLWarning = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = colorful and palette.orange or palette.statusbar_fg, - }, - SLInfo = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = colorful and palette.blue or palette.statusbar_fg, - }, - SLDiffAdd = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = colorful and palette.green or palette.statusbar_fg, - }, - SLDiffChange = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = colorful and palette.yellow or palette.statusbar_fg, - }, - SLDiffDelete = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = colorful and palette.red or palette.statusbar_fg, - }, - SLPosition = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.magenta or palette.statusbar_fg, - }, - SLFiletype = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.blue or palette.statusbar_fg, - }, - SLShiftWidth = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.yellow or palette.statusbar_fg, - }, - SLEncoding = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.green or palette.statusbar_fg, - }, - SLMode = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.green or palette.statusbar_fg, - bold = true, - }, - SLSeparatorUnused = { - bg = float and palette.float_background or palette.statusbar_bg, - fg = colorful and palette.editor_bg or palette.statusbar_fg, - }, - SLSeparator = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = float and palette.float_background or palette.statusbar_bg, - }, - SLPadding = { - bg = float and palette.editor_bg or palette.statusbar_bg, - fg = palette.editor_bg, - }, - } -end - ----@param config LualineConfig -M.custom = function(config) - local statusline_hl = util.get_highlight_value("StatusLine") - local palette = { - float_background = util.get_highlight_value("Pmenu").background, - editor_bg = util.get_highlight_value("Normal").background or "NONE", - statusbar_bg = statusline_hl.background or "#000000", - statusbar_fg = statusline_hl.foreground or "#505050", - } - local groups = generate(config, palette) - - draw(groups) - -- clear theme if float ortherwhise, make it auto - local theme = config.float and { normal = { c = { bg = palette.editor_bg } } } or "auto" - return theme -end - -return M diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua old mode 100755 new mode 100644 index a444fb2..a5bbc3b --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -1,46 +1,7 @@ -local Util = require("util") -local Icons = require("core.icons") +local Utils = require("utils") +local Icons = require("core").icons return { - { - "nvim-neo-tree/neo-tree.nvim", - cmd = "Neotree", - dependencies = "mrbjarksen/neo-tree-diagnostics.nvim", - keys = { - { - "e", - function() - require("neo-tree.command").execute({ toggle = true, position = "left", dir = require("util").get_root() }) - end, - desc = "Explorer (root dir)", - remap = true, - }, - { - "E", - function() - require("neo-tree.command").execute({ - toggle = true, - position = "float", - dir = Util.get_root(), - }) - end, - desc = "Explorer Float (root dir)", - }, - }, - opts = require("plugins.config.neo-tree"), - init = function() - vim.g.neo_tree_remove_legacy_commands = 1 - if vim.fn.argc() == 1 then - local stat = vim.loop.fs_stat(vim.fn.argv(0)) - if stat and stat.type == "directory" then - ---@diagnostic disable-next-line: different-requires - require("neo-tree") - vim.cmd([[set showtabline=0]]) - end - end - end, - }, - --╞═══════════════════════════════════════════════════════════════╡ { "serenevoid/kiwi.nvim", dependencies = { @@ -82,185 +43,44 @@ return { -- You can change it to whatever you want (eg. some nerd fonts icon), 'N' is default filetype = "md", git_branch_recognizable = false, -- If true, quicknote will separate notes by git branch - -- But it should only be used with resident mode + -- But it should only be used with resident mode }) end, dependencies = { "nvim-lua/plenary.nvim" }, }, - { - "nvim-telescope/telescope.nvim", - cmd = "Telescope", - version = "0.1.4", -- telescope did only one release, so use HEAD for now - opts = { - defaults = { - prompt_prefix = "  ", - selection_caret = "  ", - entry_prefix = " ", - borderchars = { - prompt = Util.generate_borderchars( - "thick", - nil, - { top = "█", top_left = "█", left = "█", right = " ", top_right = " ", bottom_right = " " } - ), - results = Util.generate_borderchars( - "thick", - nil, - { top = "█", top_left = "█", right = " ", top_right = " ", bottom_right = " " } - ), - preview = Util.generate_borderchars("thick", nil, { top = "█", top_left = "█", top_right = "█" }), - }, - dynamic_preview_title = true, - hl_result_eol = true, - sorting_strategy = "ascending", - file_ignore_patterns = { - ".git/", - "target/", - "docs/", - "vendor/*", - "%.lock", - "__pycache__/*", - "%.sqlite3", - "%.ipynb", - "node_modules/*", - -- "%.jpg", - -- "%.jpeg", - -- "%.png", - "%.svg", - "%.otf", - "%.ttf", - "%.webp", - ".dart_tool/", - ".github/", - ".gradle/", - ".idea/", - ".settings/", - ".vscode/", - "__pycache__/", - "build/", - "gradle/", - "node_modules/", - "%.pdb", - "%.dll", - "%.class", - "%.exe", - "%.cache", - "%.ico", - "%.pdf", - "%.dylib", - "%.jar", - "%.docx", - "%.met", - "smalljre_*/*", - ".vale/", - "%.burp", - "%.mp4", - "%.mkv", - "%.rar", - "%.zip", - "%.7z", - "%.tar", - "%.bz2", - "%.epub", - "%.flac", - "%.tar.gz", - }, - results_title = "", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - results_width = 0.8, - }, - vertical = { - mirror = false, - }, - width = 0.87, - height = 0.80, - preview_cutoff = 120, - }, - }, - }, - keys = { - -- goto - { "gd", "Telescope lsp_definitions", desc = "Go to definition" }, - { "gr", "Telescope lsp_references", desc = "Go to references" }, - { "gi", "Telescope lsp_implementations", desc = "Go to implementations" }, - -- search - { "Sb", "Telescope git_branches", desc = "Checkout branch" }, - { "Sc", "Telescope colorscheme", desc = "Colorscheme" }, - { "Sh", "Telescope help_tags", desc = "Find Help" }, - { "SM", "Telescope man_pages", desc = "Man Pages" }, - { "Sr", "Telescope oldfiles", desc = "Open Recent File" }, - { "SR", "Telescope registers", desc = "Registers" }, - { "Sk", "Telescope keymaps", desc = "Keymaps" }, - { "SC", "Telescope commands", desc = "Commands" }, - { "SH", "Telescope highlights", desc = "Highlight Groups" }, - -- Find - { "f", Util.telescope("find_files"), desc = "Find files" }, - { "F", Util.telescope("live_grep"), desc = "Find Text" }, - { "b", Util.telescope("buffers"), desc = "Find buffer" }, - }, - -- config = function() require("plugins.config.telescope") end, - }, - -- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ { "folke/which-key.nvim", event = "VeryLazy", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/popup.nvim", - "nvim-lua/plenary.nvim", - "kdheepak/lazygit.nvim", - }, opts = { - plugins = { - marks = true, -- shows a list of your marks on ' and ` - registers = true, -- shows your registers on " in NORMAL or in INSERT mode - spelling = { - enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions - suggestions = 20, -- how many suggestions should be shown in the list? - }, - - presets = { - operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion - motions = true, -- adds help for motions - text_objects = true, -- help for text objects triggered after entering an operator - windows = true, -- default bindings on - nav = true, -- misc bindings to work with windows - z = true, -- bindings for folds, spelling and others prefixed with z - g = true, -- bindings for prefixed with g - }, -- This fix mapping for fold when press f and nothing show up - }, + plugins = { spelling = true }, window = { margin = { 1, 0, 2, 0 }, -- extra window margin [top, right, bottom, left] padding = { 1, 0, 1, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 15, -- value between 0-100 0 for fully opaque and 100 for fully transparent - border = "double", - position = "bottom", - }, - popup_mappings = { - scroll_down = "", -- binding to scroll down inside the popup - scroll_up = "", -- binding to scroll up inside the popup + winblend = 5, -- value between 0-100 0 for fully opaque and 100 for fully transparent }, layout = { height = { min = 3, max = 25 }, -- min and max height of the columns - width = { min = 5, max = 50 }, -- min and max width of the columns + width = { min = 20, max = 100 }, -- min and max width of the columns spacing = 5, -- spacing between columns align = "center", -- align columns left, center or right }, + defaults = { + mode = { "n", "v" }, + ["g"] = { name = "+Git" }, + ["s"] = { name = "+Session" }, + ["c"] = { name = "+ChatGPT" }, + ["l"] = { name = "+LSP" }, + ["h"] = { name = "+Hunk" }, + ["w"] = { name = "Wiki" }, + ["g"] = { name = "+Goto" }, + ["s"] = { name = "+Search" }, + }, }, config = function(_, opts) local wk = require("which-key") wk.setup(opts) - local keymaps = { - ["h"] = { "nohlsearch", "No Highlight" }, - [""] = { "", "Navigate previous buffer" }, - ["g"] = { name = "Goto" }, - ["l"] = { name = "+LSP" }, - ["w"] = { name = "Wiki" }, - } - wk.register(keymaps) + wk.register(opts.defaults) wk.register({ C = { name = "Comment Box", @@ -394,16 +214,56 @@ return { }, { prefix = "", mode = { "n", "v" }, opts }) end, }, - -- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ + + { + "nvim-neo-tree/neo-tree.nvim", + cmd = "Neotree", + dependencies = "mrbjarksen/neo-tree-diagnostics.nvim", + keys = { + { + "e", + function() + require("neo-tree.command").execute({ toggle = true, position = "left", dir = Utils.root() }) + end, + desc = "Explorer (root dir)", + remap = true, + }, + { + "E", + function() + require("neo-tree.command").execute({ + toggle = true, + position = "float", + dir = Utils.root(), + }) + end, + desc = "Explorer Float (root dir)", + }, + }, + opts = require("features.neo-tree"), + init = function() + vim.g.neo_tree_remove_legacy_commands = 1 + if vim.fn.argc() == 1 then + local stat = vim.loop.fs_stat(vim.fn.argv(0)) + if stat and stat.type == "directory" then + ---@diagnostic disable-next-line: different-requires + require("neo-tree") + vim.cmd([[set showtabline=0]]) + end + end + end, + }, + { "lewis6991/gitsigns.nvim", + ft = { "gitcommit", "diff" }, event = { "BufReadPre", "BufNewFile" }, opts = { signs = { add = { text = Icons.gitsigns.add }, change = { text = Icons.gitsigns.change }, delete = { text = Icons.gitsigns.delete }, - topdelhfe = { text = Icons.gitsigns.topdelhfe }, + topdelhfe = { text = Icons.gitsigns.topdelete }, changedelete = { text = Icons.gitsigns.changedelete }, untracked = { text = Icons.gitsigns.untracked }, }, @@ -413,12 +273,146 @@ return { }, current_line_blame_formatter = ", - ", preview_config = { - border = Util.generate_borderchars("thick", "tl-t-tr-r-bl-b-br-l"), -- [ top top top - right - bottom bottom bottom - left ] + border = Utils.telescope.borderchars("thick", "tl-t-tr-r-br-b-bl-l"), -- [ top top top - right - bottom bottom bottom - left ] }, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + local map = Utils.safe_keymap_set + + -- Navigation + map("n", "]c", function() + if vim.wo.diff then + return "]c" + end + vim.schedule(function() + gs.next_hunk() + end) + return "" + end, { buffer = bufnr, expr = true, desc = "Next git hunk" }) + map("n", "[c", function() + if vim.wo.diff then + return "[c" + end + vim.schedule(function() + gs.prev_hunk() + end) + return "" + end, { buffer = bufnr, expr = true, desc = "Previous git hunk" }) + + -- Actions + map("n", "hs", gs.stage_hunk, { desc = "Stage current hunk" }) + map("n", "hr", gs.reset_hunk, { desc = "Reset current hunk" }) + map("v", "hs", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, { desc = "Stage visual selection" }) + map("v", "hr", function() + gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, { desc = "Reset visual selection" }) + map("n", "hS", gs.stage_buffer, { desc = "Stage entire buffer" }) + map("n", "hu", gs.undo_stage_hunk, { desc = "Undo last hunk staging" }) + map("n", "hR", gs.reset_buffer, { desc = "Reset entire buffer" }) + map("n", "hp", gs.preview_hunk, { desc = "Preview current hunk changes" }) + map("n", "hb", function() + gs.blame_line({ full = true }) + end, { desc = "Show blame for current line" }) + map("n", "tb", gs.toggle_current_line_blame, { desc = "Toggle blame for current line" }) + map("n", "hd", gs.diffthis, { desc = "Diff current hunk" }) + map("n", "hD", function() + gs.diffthis("~") + end, { desc = "Diff all changes in the file" }) + end, + }, + }, + + { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + version = false, -- telescope did only one release, so use HEAD for now + opts = function() + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") + local is_telescope_bg_clear = vim.tbl_contains(monokai_opts.background_clear or {}, "telescope") + local opts = { + defaults = { + prompt_prefix = "  ", + selection_caret = "  ", + entry_prefix = " ", + borderchars = is_telescope_bg_clear and Utils.telescope.borderchars("rounded") + or { + prompt = Utils.telescope.borderchars("thick", nil, { + top = "▄", + top_left = "▄", + left = "█", + right = " ", + top_right = " ", + bottom_right = " ", + }), + results = Utils.telescope.borderchars( + "thick", + nil, + { top = "█", top_left = "█", right = " ", top_right = " ", bottom_right = " " } + ), + preview = Utils.telescope.borderchars("thick", nil, { top = "▄", top_left = "▄", top_right = "▄" }), + }, + dynamic_preview_title = true, + hl_result_eol = true, + sorting_strategy = "ascending", + results_title = "", -- Remove `Results` title + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + mirror = false, + }, + width = 0.8, + height = 0.80, + preview_cutoff = 120, + }, + mappings = { + n = { ["q"] = require("telescope.actions").close }, + }, + }, + } + return opts + end, + keys = { + -- goto + { "gd", "Telescope lsp_definitions", desc = "Go to definition" }, + { "gr", "Telescope lsp_references", desc = "Go to references" }, + { "gi", "Telescope lsp_implementations", desc = "Go to implementations" }, + -- search + { "sb", "Telescope git_branches", desc = "Checkout branch" }, + { "sc", "Telescope colorscheme", desc = "Colorscheme" }, + { "sh", "Telescope help_tags", desc = "Find Help" }, + { "sM", "Telescope man_pages", desc = "Man Pages" }, + { "sr", "Telescope oldfiles", desc = "Open Recent File" }, + { "sR", "Telescope registers", desc = "Registers" }, + { "sk", "Telescope keymaps", desc = "Keymaps" }, + { "sC", "Telescope commands", desc = "Commands" }, + { "sH", "Telescope highlights", desc = "Highlight Groups" }, + -- Git + { "go", "Telescope git_status", desc = "Open changed file" }, + { "gb", "Telescope git_branches", desc = "Checkout branch" }, + { "gc", "Telescope git_commits", desc = "Checkout commit" }, + -- Find + { "f", Utils.telescope("find_files"), desc = "Find files" }, + { "F", Utils.telescope("live_grep"), desc = "Find Text" }, + { "b", Utils.telescope("buffers"), desc = "Find buffer" }, + }, + }, + + { + "moll/vim-bbye", + event = { "BufRead" }, + keys = { + { "d", "Bdelete!", desc = "Close Buffer" }, + { "", "Bdelete!", desc = "Close Buffer" }, }, - keys = {}, }, - -- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ + + -- TODO: Remove this when upgrading Neovim to version >= 0.10.0. -- references { "RRethy/vim-illuminate", @@ -471,45 +465,4 @@ return { { "[[", desc = "Prev Reference" }, }, }, - -- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ - { - "luukvbaal/statuscol.nvim", - event = { "BufReadPost", "BufNewFile" }, - config = function() - local builtin = require("statuscol.builtin") - require("statuscol").setup({ - relculright = false, - ft_ignore = { "neo-tree" }, - segments = { - { - -- line number - text = { " ", builtin.lnumfunc }, - condition = { true, builtin.not_empty }, - click = "v:lua.ScLa", - }, - { text = { "%s" }, click = "v:lua.ScSa" }, -- Sign - { text = { builtin.foldfunc, " " }, click = "v:lua.ScFa" }, -- Fold - }, - }) - vim.api.nvim_create_autocmd({ "BufEnter" }, { - callback = function() - if vim.bo.filetype == "neo-tree" then - vim.opt_local.statuscolumn = "" - end - end, - }) - end, - }, ---───────────────────────────────────────────────────────────────── - { - "nvim-pack/nvim-spectre", - build = false, - cmd = "Spectre", - opts = { open_cmd = "noswapfile vnew" }, - -- stylua: ignore - keys = { - { "sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)" }, - }, - }, --- ───────────────────────────────────────────────────────────────── } diff --git a/lua/plugins/formatting.lua b/lua/plugins/formatting.lua old mode 100755 new mode 100644 index e1a0033..6a37d4d --- a/lua/plugins/formatting.lua +++ b/lua/plugins/formatting.lua @@ -1,5 +1,6 @@ return { "stevearc/conform.nvim", + dependencies = { "mason.nvim" }, event = { "BufWritePre" }, cmd = { "ConformInfo" }, opts = { @@ -17,7 +18,7 @@ return { function() local cf = require("conform") cf.format({ async = false, lsp_fallback = true }) - vim.cmd([[wa!]]) + vim.cmd([[w!]]) end, desc = "Format and save", }, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..5dbd8e4 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,3 @@ +require("core").init() + +return {} diff --git a/lua/plugins/lang/clangd.lua b/lua/plugins/lang/clangd.lua deleted file mode 100755 index e64b691..0000000 --- a/lua/plugins/lang/clangd.lua +++ /dev/null @@ -1,90 +0,0 @@ -return { - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "c", "cpp" }) - end - end, - }, - - { - "p00f/clangd_extensions.nvim", - lazy = true, - config = function() end, - opts = { - inlay_hints = { - inline = false, - }, - ast = { - role_icons = { - type = "", - declaration = "", - expression = "", - specifier = "", - statement = "", - ["template argument"] = "", - }, - kind_icons = { - Compound = "", - Recovery = "", - TranslationUnit = "", - PackExpansion = "", - TemplateTypeParm = "", - TemplateTemplateParm = "", - TemplateParamObject = "", - }, - }, - }, - }, - - -- Correctly setup lspconfig for clangd 🚀 - { - "neovim/nvim-lspconfig", - opts = { - servers = { - -- Ensure mason installs the server - clangd = { - keys = { - { "lR", "ClangdSwitchSourceHeader", desc = "Switch Source/Header (C/C++)" }, - }, - root_dir = function(fname) - return require("lspconfig.util").root_pattern( - "Makefile", - "configure.ac", - "configure.in", - "plugins.config.h.in", - "meson.build", - "meson_options.txt", - "build.ninja" - )(fname) or require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt")( - fname - ) or require("lspconfig.util").find_git_ancestor(fname) - end, - cmd = { - "clangd", - "--background-index", - "--clang-tidy", - "--header-insertion=iwyu", - "--completion-style=detailed", - "--function-arg-placeholders", - "--fallback-style=llvm", - }, - init_options = { - usePlaceholders = true, - completeUnimported = true, - clangdFileStatus = true, - }, - }, - }, - setup = { - clangd = function(_, opts) - local clangd_ext_opts = require("util").opts("clangd_extensions.nvim") - require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts })) - return false - end, - }, - }, - }, - -} diff --git a/lua/plugins/linting.lua b/lua/plugins/linting.lua new file mode 100644 index 0000000..eb331f3 --- /dev/null +++ b/lua/plugins/linting.lua @@ -0,0 +1,16 @@ +return { + { + "mfussenegger/nvim-lint", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + opts = { + linters_by_ft = { + markdown = { "vale" }, + lua = { "luacheck" }, + }, + }, + config = function(_, opts) + local lint = require("lint") + local names = lint._resolve_linter_by_ft(vim.bo.filetype) + end, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua old mode 100755 new mode 100644 index cf779d3..ecaabba --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,3 +1,5 @@ +local Icons = require("core").icons + return { { "neovim/nvim-lspconfig", @@ -7,43 +9,27 @@ return { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", }, + ---@type LspOptions opts = { servers = { html = {}, lua_ls = { settings = { Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - hint = { enable = true }, diagnostics = { - enable = true, - globals = { - "vim", - "nnoremap", - "vnoremap", - "inoremap", - "tnoremap", - "use", - }, + globals = { "vim" }, }, workspace = { checkThirdParty = false, library = { - vim.api.nvim_get_runtime_file("", true), - ["$HOME/awesome-code-doc"] = true, [vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, + [vim.fn.stdpath("data") .. "/lazy/lazy.nvim/lua/lazy"] = true, }, - -- adjust these two values if your performance is not optimal - maxPreload = 2000, - preloadFileSize = 2000, + maxPreload = 100000, + preloadFileSize = 10000, }, - telemetry = { enable = false }, - completion = { callSnippet = "Replace", }, @@ -64,118 +50,50 @@ return { }, }, }, - ---@type table - attach_handlers = {}, capabilities = { textDocument = { foldingRange = { dynamicRegistration = false, lineFoldingOnly = true }, + completion = { + completionItem = { + documentationFormat = { "markdown", "plaintext" }, + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + }, + }, + }, }, }, + diagnostics = true, }, - config = function(_, opts) - local Util = require("util") - -- special attach lsp - Util.on_attach(function(client, buffer) - require("plugins.config.lsp.keymaps").attach(client, buffer) - require("plugins.config.lsp.gitsigns").attach(client, buffer) - end) - - -- diagnostics - vim.diagnostic.config(require("plugins.config.lsp.diagnostics")["on"]) - - local servers = opts.servers - local ext_capabilites = vim.lsp.protocol.make_client_capabilities() - - -- inlay hints - local inlay_hint = vim.lsp.buf.inlayhints or vim.lsp.inlayhints - if vim.fn.has("nvim-0.10.0") and inlay_hint then - Util.on_attach(function(client, buffer) - if client.supports_method("textDocument/inlayHint") then - inlay_hint(buffer, true) - end - end) - end - - local capabilities = vim.tbl_deep_extend( - "force", - {}, - ext_capabilites, - require("cmp_nvim_lsp").default_capabilities(), - opts.capabilities - ) - - local function setup(server) - local server_opts = vim.tbl_deep_extend("force", { - capabilities = vim.deepcopy(capabilities), - }, servers[server] or {}) - - if opts.attach_handlers[server] then - local callback = function(client, buffer) - if client.name == server then - opts.attach_handlers[server](client, buffer) - end - end - Util.on_attach(callback) - end - require("lspconfig")[server].setup(server_opts) - end - - local available = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) - - local ensure_installed = {} - for server, server_opts in pairs(servers) do - if server_opts then - if not vim.tbl_contains(available, server) then - setup(server) - else - ensure_installed[#ensure_installed + 1] = server - end - end - end - - require("mason-lspconfig").setup({ ensure_installed = ensure_installed }) - require("mason-lspconfig").setup_handlers({ setup }) + require("features.lsp").setup(opts) end, }, - -- ───────────────────────────────────────────────────────────────── - -- Schema Store [lsp schema manager] - -- https://github.com/b0o/SchemaStore.nvim - "b0o/SchemaStore.nvim", - --───────────────────────────────────────────────────────────────── { "williamboman/mason.nvim", cmd = "Mason", opts = { - registries = { - "github:nvim-java/mason-registry", - "github:mason-org/mason-registry", - }, ensure_installed = { - -- LSPs - "bash-language-server", - "clangd", - "jdtls", - "dockerfile-language-server", - "json-lsp", - "marksman", - "typescript-language-server", - "texlab", - "ltex-ls", - "lua-language-server", - "pyright", - "terraform-ls", - "yaml-language-server", - -- Formatter - "black", - "prettier", "stylua", - "shfmt", - -- Linter - "shellcheck", - "tflint", - "yamllint", + }, + ui = { + icons = { + package_pending = Icons.mason.pending, + package_installed = Icons.mason.installed, + package_uninstalled = Icons.mason.uninstalled, + }, }, }, config = function(_, opts) @@ -196,7 +114,6 @@ return { end end, }, - { "folke/trouble.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, @@ -206,7 +123,7 @@ return { width = 50, -- width of the list when position is left or right icons = true, -- use devicons for filenames mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" - severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT + severity = nil, -- nil (all) or vim.diagnostic.severity.error | warn | info | hint fold_open = "", -- icon used for open folds fold_closed = "", -- icon used for closed folds group = true, -- group results by file @@ -225,20 +142,20 @@ return { jump_close = { "o" }, -- jump to the diagnostic and close the list toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode switch_severity = "s", -- switch "diagnostics" severity filter level - toggle_preview = "P", -- toggle auto_preview - hover = "K", -- opens a small popup with the full multiline message + toggle_preview = "p", -- toggle auto_preview + hover = "k", -- opens a small popup with the full multiline message preview = "p", -- preview the diagnostic location - open_code_href = "c", -- if present, open a URI with more information about the diagnostic error - close_folds = { "zM", "zm" }, -- close all folds - open_folds = { "zR", "zr" }, -- open all folds - toggle_fold = { "zA", "za" }, -- toggle fold of current file + open_code_href = "c", -- if present, open a uri with more information about the diagnostic error + close_folds = { "zm", "zm" }, -- close all folds + open_folds = { "zr", "zr" }, -- open all folds + toggle_fold = { "za", "za" }, -- toggle fold of current file previous = "k", -- previous item next = "j", -- next item help = "?", -- help menu }, multiline = true, -- render multi-line messages indent_lines = true, -- add an indent guide below the fold icons - win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|. + win_config = { border = "single" }, -- window configuration for floating windows. see |nvim_open_win()|. auto_open = false, -- automatically open the list when you have diagnostics auto_close = false, -- automatically close the list when you have no diagnostics auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window @@ -259,7 +176,7 @@ return { -- ───────────────────────────────────────────────────────────────── { "zeioth/garbage-day.nvim", - event = "User BaseFile", + event = "user basefile", opts = { aggressive_mode = false, excluded_lsp_clients = { @@ -275,7 +192,7 @@ return { }, { "nvimtools/none-ls.nvim", - event = { "BufReadPre", "BufNewFile" }, + event = { "bufreadpre", "bufnewfile" }, dependencies = { "mason.nvim", "jay-babu/mason-null-ls.nvim" }, root_has_file = function(files) return function(utils) @@ -297,7 +214,7 @@ return { } return { debug = false, - -- You can then register sources by passing a sources list into your setup function: + -- you can then register sources by passing a sources list into your setup function: -- using `with()`, which modifies a subset of the source's default options sources = { formatting.stylua.with(modifier.stylua_formatting), diff --git a/lua/plugins/settings.lua b/lua/plugins/settings.lua deleted file mode 100755 index 7be49b6..0000000 --- a/lua/plugins/settings.lua +++ /dev/null @@ -1,14 +0,0 @@ -local util = require("util") - --- autocmds and keymaps can wait to load -vim.api.nvim_create_autocmd("User", { - pattern = "VeryLazy", - callback = function() - util.load("autocmds") - util.load("keymaps") - end, -}) - -util.load("options") - -return {} diff --git a/lua/plugins/shared.lua b/lua/plugins/shared.lua new file mode 100644 index 0000000..3bb815f --- /dev/null +++ b/lua/plugins/shared.lua @@ -0,0 +1,4 @@ +return { + -- Common library used by many plugins + { "nvim-lua/plenary.nvim", lazy = true }, +} diff --git a/lua/plugins/tools.lua b/lua/plugins/tools.lua old mode 100755 new mode 100644 index e183b38..3076dca --- a/lua/plugins/tools.lua +++ b/lua/plugins/tools.lua @@ -1,29 +1,8 @@ return { - { "mg979/vim-visual-multi", event = { "BufReadPost", "BufNewFile" }, }, - - -- ╞═══════════════════════════════════════════════════════════════╡ - { - "loctvl842/compile-nvim", - lazy = true, - config = function() - require("plugins.config.compile") - end, - }, - -- ╞═══════════════════════════════════════════════════════════════╡ - { - "moll/vim-bbye", - event = { "BufRead" }, - keys = { - { "d", "Bdelete!", desc = "Close Buffer" }, - { "", "Bdelete!", desc = "Close Buffer" }, - }, - }, - -- ╞═══════════════════════════════════════════════════════════════╡ - -- Easily switch virtual environment in python { "AckslD/swenv.nvim", config = function() diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua old mode 100755 new mode 100644 index a56940f..bef9df7 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -3,9 +3,21 @@ return { "nvim-treesitter/nvim-treesitter", version = false, -- last release is way too old and doesn't work on Windows build = ":TSUpdate", - event = { "BufReadPost", "BufNewFile" }, + event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, + init = function(plugin) + --- Reference: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/treesitter.lua#L10 + -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early + -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which + -- no longer trigger the **nvim-treeitter** module to be loaded in time. + -- Luckily, the only thins that those plugins need are the custom queries, which we make available + -- during startup. + require("lazy.core.loader").add_to_rtp(plugin) + require("nvim-treesitter.query_predicates") + end, + cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, opts = { ensure_installed = { + "vimdoc", "bash", "c", "comment", @@ -45,80 +57,32 @@ return { }, highlight = { enable = true }, indent = { enable = true, disable = { "yaml", "python", "html" } }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - scope_incremental = "", - node_incremental = "", - node_decremental = "", - }, - }, - endwise = { + rainbow = { enable = true, + query = "rainbow-parens", + disable = { "jsx", "html" }, }, - autopairs = { enable = true }, - textobjects = { - select = { - enable = true, - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - ["al"] = "@loop.outer", - ["il"] = "@loop.inner", - ["ib"] = "@block.inner", - ["ab"] = "@block.outer", - ["ir"] = "@parameter.inner", - ["ar"] = "@parameter.outer", - }, - }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + }, - context_commentstring = { enable = true }, - rainbow = { - enable = true, - query = "rainbow-parens", - disable = { "jsx", "html" }, - }, - }, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) - require("nvim-ts-autotag").setup() - end, + -- Show context of the current function + { + "nvim-treesitter/nvim-treesitter-context", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + enabled = true, + opts = { mode = "cursor", max_lines = 3 }, + keys = { + { "ut", "TSContextToggle", desc = "Toggle Treesitter Context" }, }, }, ---───────────────────────────────────────────────────────────────── + { "HiPhish/rainbow-delimiters.nvim", - init = function() - local rainbow_delimiters = require("rainbow-delimiters") - - vim.g.rainbow_delimiters = { - strategy = { - [""] = rainbow_delimiters.strategy["global"], - vim = rainbow_delimiters.strategy["local"], - }, - query = { - [""] = "rainbow-delimiters", - lua = "rainbow-blocks", - }, - highlight = { - "RainbowDelimiterRed", - "RainbowDelimiterYellow", - "RainbowDelimiterBlue", - "RainbowDelimiterOrange", - "RainbowDelimiterGreen", - "RainbowDelimiterViolet", - "RainbowDelimiterCyan", - }, - } - end, + lazy = true, }, ---───────────────────────────────────────────────────────────────── { "nvim-treesitter/nvim-treesitter-textobjects", config = function() @@ -144,11 +108,5 @@ return { end end, }, ---───────────────────────────────────────────────────────────────── - { - "nvim-treesitter/nvim-treesitter-context", - event = "BufRead", - enabled = true, - opts = { mode = "cursor", max_lines = 3 }, - }, + } diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua old mode 100755 new mode 100644 index 18982dc..7fe03aa --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -1,14 +1,19 @@ -local Util = require("util") -local Icon = require("core.icons") + local Icons = require("core").icons +local Logos = require("core.logos") +local Utils = require("utils") return { - -- ───────────────────────────────────────────────────────────────── - -- Notifications styler with useful notifications clear command + -- UI components + { "MunifTanjim/nui.nvim", lazy = true }, + + -- icons + { "nvim-tree/nvim-web-devicons", lazy = true }, + { "rcarriga/nvim-notify", keys = { { - "N", + "n", function() require("notify").dismiss({ silent = true, pending = true }) end, @@ -17,9 +22,9 @@ return { }, opts = { icons = { - ERROR = Icon.diagnostics.error .. " ", - INFO = Icon.diagnostics.info .. " ", - WARN = Icon.diagnostics.warn .. " ", + ERROR = Icons.diagnostics.error .. " ", + INFO = Icons.diagnostics.info .. " ", + WARN = Icons.diagnostics.warn .. " ", }, timeout = 3000, max_height = function() @@ -30,15 +35,33 @@ return { end, }, init = function() - if not Util.has("noice.nvim") then - Util.on_very_lazy(function() + if not Utils.plugin.has("noice.nvim") then + Utils.on_very_lazy(function() vim.notify = require("notify") end) end end, }, - -- ───────────────────────────────────────────────────────────────── - -- buffers listed as tabs above editor window interface + + { + "nvim-lualine/lualine.nvim", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + opts = function() + local lualine_require = require("lualine_require") + lualine_require.require = require + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") + return { + float = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), + colorful = true, + } + end, + config = function(_, opts) + local lualine = require("features.lualine") + lualine.setup(opts) + lualine.load() + end, + }, + { "akinsho/bufferline.nvim", event = { "BufReadPost", "BufNewFile" }, @@ -58,12 +81,12 @@ return { { "", "BufferLineMovePrev", desc = "Move buffer left" }, }, opts = function() - local monokai_opts = require("util").opts("monokai-pro.nvim") + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") return { options = { diagnostics = "nvim_lsp", -- | "nvim_lsp" | "coc", - -- separator_style = "", -- | "thick" | "thin" | "slope" | { 'any', 'any' }, - separator_style = { "thick", "thick" }, -- | "thick" | "thin" | { 'any', 'any' }, + -- separator_style = "", -- | "thick" | "thin" | "slope" | { 'any', 'any' }, + separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' }, -- separator_style = "slant", -- | "thick" | "thin" | { 'any', 'any' }, indicator = { -- icon = " ", @@ -82,13 +105,13 @@ return { filetype = "neo-tree", text = "EXPLORER", text_align = "center", - separator = not vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), -- set to `true` if clear background of neo-tree + separator = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), -- set to `true` if clear background of neo-tree }, { filetype = "NvimTree", text = "EXPLORER", text_align = "center", - separator = not vim.tbl_contains(monokai_opts.background_clear or {}, "nvim-tree"), -- set to `true` if clear background of neo-tree + separator = vim.tbl_contains(monokai_opts.background_clear or {}, "nvim-tree"), -- set to `true` if clear background of neo-tree }, }, hover = { @@ -100,123 +123,10 @@ return { } end, }, - -- ───────────────────────────────────────────────────────────────── - -- Status bar below editor window with some useful information I never look at - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function() - local monokai_opts = require("util").opts("monokai-pro.nvim") - return { - float = not vim.tbl_contains({}, "neo-tree"), - separator = "bubble", -- bubble | triangle - ---@type any - colorful = true, - } - end, - config = function(_, opts) - local lualine_config = require("plugins.config.lualine") - lualine_config.setup(opts) - lualine_config.load() - end, - }, - -- ───────────────────────────────────────────────────────────────── - -- provides identation guides - { - "lukas-reineke/indent-blankline.nvim", - event = { "BufReadPost", "BufNewFile" }, - opts = function() - local hooks = require("ibl.hooks") - hooks.register(hooks.type.SCOPE_ACTIVE, function(bufnr) - return vim.api.nvim_buf_line_count(bufnr) < 2000 - end) - - local highlight = { - "RainbowDelimiterRed", - "RainbowDelimiterYellow", - "RainbowDelimiterBlue", - "RainbowDelimiterOrange", - "RainbowDelimiterGreen", - "RainbowDelimiterViolet", - "RainbowDelimiterCyan", - } - return { - debounce = 200, - indent = { - char = "▏", - tab_char = "▏", - }, - scope = { - injected_languages = true, - highlight = highlight, - show_start = true, - show_end = false, - char = "▏", - include = { - node_type = { ["*"] = { "*" } }, - }, - exclude = { - node_type = { ["*"] = { "source_file", "program" }, python = { "module" }, lua = { "chunk" } }, - }, - }, - exclude = { - filetypes = { - "help", - "startify", - "dashboard", - "packer", - "neogitstatus", - "NvimTree", - "Trouble", - "alpha", - "neo-tree", - }, - buftypes = { - "terminal", - "nofile", - }, - }, - } - end, - main = "ibl", - }, - -- ───────────────────────────────────────────────────────────────── - -- provides indentation support using pipe symbol - { - "echasnovski/mini.indentscope", - lazy = true, - enabled = true, - -- lazy = true, - version = false, -- wait till new 0.7.0 release to put it back on semver - event = "BufReadPre", - opts = { - symbol = "▏", - -- symbol = "│", - options = { try_as_border = false }, - }, - config = function(_, opts) - vim.api.nvim_create_autocmd("FileType", { - pattern = { - "help", - "alpha", - "dashboard", - "neo-tree", - "Trouble", - "lazy", - "mason", - }, - callback = function() - vim.b.miniindentscope_disable = true - end, - }) - require("mini.indentscope").setup(opts) - end, - }, - -- ───────────────────────────────────────────────────────────────── { "utilyre/barbecue.nvim", - event = { "BufReadPost", "BufNewFile" }, + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, dependencies = { "SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons", @@ -227,64 +137,105 @@ return { include_buftypes = { "" }, exclude_filetypes = { "gitcommit", "Trouble", "toggleterm" }, show_modified = false, - kinds = Icon.kinds, - }, - }, - -- ───────────────────────────────────────────────────────────────── - -- my finally functional terminal popup that works with NixOS - { - "akinsho/toggleterm.nvim", - event = { "BufReadPost", "BufNewFile" }, - opts = { - open_mapping = [[]], - hide_numbers = true, - shade_filetypes = {}, - shade_terminals = true, - shading_factor = "1", - start_in_insert = true, - direction = "float", - insert_mappings = true, - persist_size = true, - close_on_exit = false, - shell = "/run/current-system/sw/bin/zsh", - autochdir = false, - float_opts = { - border = "single", - winblend = 3, - width = 85, - height = 55, - highlights = { - border = "Normal", - background = "Normal", - }, - }, - winbar = { - enabled = false, - name_formatter = function(term) - return term.name - end, - }, + kinds = Icons.kinds, }, }, - -- ───────────────────────────────────────────────────────────────── - -- a dashboard for that rare situation I open nvim without any particular file in mind + { - "glepnir/dashboard-nvim", + "nvimdev/dashboard-nvim", event = "VimEnter", dependencies = { { "nvim-tree/nvim-web-devicons" } }, keys = { { "0", "Dashboard", desc = "Dashboard" } }, - config = function() - require("plugins.config.dashboard") + opts = function() + local opts = { + theme = "doom", + hide = { + statusline = 0, + tabline = 0, + winbar = 0, + }, + config = { + header = Logos.logos.random(), + center = { + { + action = "Telescope oldfiles", + desc = "Recent Files", + key = "r", + icon = " ", + icon_hl = "DashboardRecent", + key_hl = "DashboardRecent", + }, + { + action = "lua require('persistence').load({last = true})", + desc = "Last Session", + key = "s", + icon = " ", + icon_hl = "DashboardSession", + key_hl = "DashboardSession", + }, + { + icon = " ", + icon_hl = "DashboardConfiguration", + desc = "Configuration", + key = "i", + key_hl = "DashboardConfiguration", + action = "edit $MYVIMRC", + }, + { + icon = "󰤄 ", + icon_hl = "DashboardLazy", + desc = "Lazy", + key = "l", + key_hl = "DashboardLazy", + action = "Lazy", + }, + { + icon = " ", + icon_hl = "DashboardServer", + desc = "Mason", + key = "m", + key_hl = "DashboardServer", + action = "Mason", + }, + { + icon = " ", + icon_hl = "DashboardQuit", + desc = "Quit Neovim", + key = "q", + key_hl = "DashboardQuit", + action = "qa", + }, + }, + footer = function() + ---@diagnostic disable-next-line: different-requires + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { + "⚡  eovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms", + } + end, + }, + } + for _, button in pairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 45 - #button.desc) + button.icon = button.icon .. string.rep(" ", 5 - #button.icon) + end + + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + pattern = "DashboardLoaded", + callback = function() + ---@diagnostic disable-next-line: different-requires + require("lazy").show() + end, + }) + end + return opts end, }, - -- ───────────────────────────────────────────────────────────────── - -- icons for nvim-tree - { - "nvim-tree/nvim-web-devicons", - lazy = true, - }, - -- ───────────────────────────────────────────────────────────────── - -- scrollbars for nvim + { "petertriho/nvim-scrollbar", event = { "BufReadPost", "BufNewFile" }, @@ -307,8 +258,7 @@ return { }, }, }, - -- ───────────────────────────────────────────────────────────────── - -- window animations are fun + { "anuvyklack/windows.nvim", event = "WinNew", @@ -327,39 +277,82 @@ return { vim.o.equalalways = true end, }, - -- ───────────────────────────────────────────────────────────────── - -- because I am still not able to translate hex codes to colors in my head - { - "norcalli/nvim-colorizer.lua", - event = "BufReadPre", - init = function() - require("colorizer").setup() - end, - }, - -- ───────────────────────────────────────────────────────────────── + -- better vim.ui { "stevearc/dressing.nvim", - lazy = false, - opts = { - input = { - border = Util.generate_borderchars("thick", "tl-t-tr-r-bl-b-br-l"), - win_options = { winblend = 0 }, - }, - select = { telescope = Util.telescope_theme("cursor") }, - }, + event = { "BufReadPost", "BufNewFile" }, + opts = function() + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") + local border_style = vim.tbl_contains(monokai_opts.background_clear or {}, "float_win") and "rounded" or "thick" + return { + input = { + border = Utils.telescope.borderchars(border_style, "tl-t-tr-r-br-b-bl-l"), + win_options = { winblend = 0 }, + }, + select = vim.tbl_contains(monokai_opts.background_clear or {}, "telescope") and {} or { + telescope = Utils.telescope.theme("cursor", "thick"), + }, + } + end, init = function() vim.ui.select = function(...) + ---@diagnostic disable-next-line: different-requires require("lazy").load({ plugins = { "dressing.nvim" } }) return vim.ui.select(...) end vim.ui.input = function(...) + ---@diagnostic disable-next-line: different-requires require("lazy").load({ plugins = { "dressing.nvim" } }) return vim.ui.input(...) end end, }, - -- ───────────────────────────────────────────────────────────────── + + { + "echasnovski/mini.hipatterns", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + opts = function() + local hi = require("mini.hipatterns") + return { + highlighters = { + -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE' + fixme = { pattern = "%f[%w]()FIXME()%f[%W]", group = "MiniHipatternsFixme" }, + hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, + todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, + note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" }, + -- Highlight hex color strings (`#rrggbb`) using that color + hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }), + }, + } + end, + }, + + { + "kosayoda/nvim-lightbulb", + opts = { + sign = { + enabled = true, + -- Priority of the gutter sign + priority = 20, + }, + status_text = { + enabled = true, + -- Text to provide when code actions are available + text = "status_text", + -- Text to provide when no actions are available + text_unavailable = "", + }, + autocmd = { + enabled = true, + -- see :help autocmd-pattern + pattern = { "*" }, + -- see :help autocmd-events + events = { "CursorHold", "CursorHoldI", "LspAttach" }, + }, + }, + }, + -- noicer ui { "folke/noice.nvim", @@ -370,14 +363,20 @@ return { view = "cmdline", format = { cmdline = { icon = "  " }, - search_down = { icon = "  󰄼" }, - search_up = { icon = "  " }, + search_down = { icon = " 🔍 󰄼" }, + search_up = { icon = " 🔍 " }, + help = { icon = " 󰋖" }, lua = { icon = "  " }, }, }, lsp = { - progress = { enabled = true }, - hover = { enabled = true }, + progress = { + enabled = true, + format = "lsp_progress", + format_done = "lsp_progress_done", + view = "mini", + }, + hover = { enabled = false }, signature = { enabled = false }, -- override markdown rendering so that **cmp** and other plugins use **Treesitter** override = { @@ -390,72 +389,121 @@ return { { filter = { event = "msg_show", - find = "%d+L, %d+B", + any = { + { find = "%d+L, %d+B" }, + { find = "No active Snippet" }, + { find = "; after #%d+" }, + { find = "; before #%d+" }, + { find = "Hunk" }, + }, + }, + view = "mini", + }, + { + filter = { + event = "notify", + any = { + { find = "No information available" }, + }, }, }, }, }, }, - --───────────────────────────────────────────────────────────────── - -- ease neovim development somehow I don't remember - { - "folke/neodev.nvim", - lazy = true, - }, - -- ───────────────────────────────────────────────────────────────── - -- TODO:Move this to coding or lang/java - { - "mfussenegger/nvim-jdtls", - ft = "java", - }, - -- ───────────────────────────────────────────────────────────────── - -- dependency of many other things, probably not needed here but mitigates issues because it is - { - "nvim-lua/plenary.nvim", - lazy = true, - }, - -- ───────────────────────────────────────────────────────────────── - -- Adds things like :Move, :Rename, :SudoWrite, etc. - { "tpope/vim-eunuch", event = "VeryLazy" }, - -- ───────────────────────────────────────────────────────────────── - -- useful popup windows + { - "anuvyklack/hydra.nvim", - dependencies = { - "anuvyklack/keymap-layer.nvim", - }, - config = function() - require("plugins.config.hydra.hydra") + "lukas-reineke/indent-blankline.nvim", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + opts = function() + local hooks = require("ibl.hooks") + hooks.register(hooks.type.SCOPE_ACTIVE, function(bufnr) + return vim.api.nvim_buf_line_count(bufnr) < 2000 + end) + + local highlight = { + "RainbowDelimiterRed", + "RainbowDelimiterYellow", + "RainbowDelimiterBlue", + "RainbowDelimiterOrange", + "RainbowDelimiterGreen", + "RainbowDelimiterViolet", + "RainbowDelimiterCyan", + } + return { + debounce = 200, + indent = { + char = "▏", + tab_char = "▏", + -- highlight = "IndentBlanklineChar", + -- highlight = highlight, + }, + scope = { + injected_languages = true, + highlight = highlight, + enabled = true, + show_start = true, + show_end = false, + char = "▏", + -- include = { + -- node_type = { ["*"] = { "*" } }, + -- }, + -- exclude = { + -- node_type = { ["*"] = { "source_file", "program" }, python = { "module" }, lua = { "chunk" } }, + -- }, + }, + exclude = { + filetypes = { + "help", + "startify", + "dashboard", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", + "alpha", + "neo-tree", + }, + buftypes = { + "terminal", + "nofile", + }, + }, + } end, + main = "ibl", }, - -- ───────────────────────────────────────────────────────────────── - -- window picking when opening a buffer with splits open { - "s1n7ax/nvim-window-picker", - lazy = false, + "akinsho/toggleterm.nvim", + event = { "BufReadPost", "BufNewFile" }, opts = { - autoselect_one = true, - include_current = false, - filter_rules = { - -- filter using buffer options - bo = { - -- if the file type is one of following, the window will be ignored - filetype = { - "neo-tree", - "neo-tree-popup", - "notify", - "packer", - "qf", - "diff", - "fugitive", - "fugitiveblame", - }, - - -- if the buffer type is one of following, the window will be ignored - buftype = { "nofile", "help", "terminal" }, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = "1", + start_in_insert = true, + direction = "float", + insert_mappings = true, + persist_size = true, + close_on_exit = false, + shell = "/run/current-system/sw/bin/zsh", + autochdir = false, + float_opts = { + border = "single", + winblend = 3, + width = 85, + height = 55, + highlights = { + border = "Normal", + background = "Normal", }, }, - other_win_hl_color = "#948ae3", + winbar = { + enabled = false, + name_formatter = function(term) + return term.name + end, + }, }, }, } diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua deleted file mode 100755 index 8962afb..0000000 --- a/lua/plugins/util.lua +++ /dev/null @@ -1,50 +0,0 @@ -return { - - { - "nvim-lua/plenary.nvim", - lazy = true, - }, - - { - "MunifTanjim/nui.nvim", - lazy = true, - }, - - { - "dstein64/vim-startuptime", - cmd = "StartupTime", - }, - - { - "sudormrfbin/cheatsheet.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/popup.nvim", - "nvim-lua/plenary.nvim", - }, - config = function() - require("cheatsheet").setup({ - -- Whether to show bundled cheatsheets - - -- For generic cheatsheets like default, unicode, nerd-fonts, etc - bundled_cheatsheets = true, - - -- For plugin specific cheatsheets - bundled_plugin_cheatsheets = true, - - -- For bundled plugin cheatsheets, do not show a sheet if you - -- don't have the plugin installed (searches runtimepath for - -- same directory name) - include_only_installed_plugins = true, - - -- Key mappings bound inside the telescope window - telescope_mappings = { - [""] = require("cheatsheet.telescope.actions").select_or_fill_commandline, - [""] = require("cheatsheet.telescope.actions").select_or_execute, - [""] = require("cheatsheet.telescope.actions").copy_cheat_value, - [""] = require("cheatsheet.telescope.actions").edit_user_cheatsheet, - }, - }) - end, - }, -} diff --git a/lua/profile.lua b/lua/profile.lua new file mode 100644 index 0000000..c221181 --- /dev/null +++ b/lua/profile.lua @@ -0,0 +1,16 @@ +---@class Profile +---@field name string -- Your editor name +---@field author? string +---@field version? string +---@field license? string +local M = { + name = "nvim-forge", +} +M = setmetatable({}, { __index = M }) + +---@param opts? Profile +function M.setup(opts) + M = vim.tbl_deep_extend("force", M, opts or {}) +end + +return M diff --git a/lua/util.lua b/lua/util.lua deleted file mode 100755 index 53aeb80..0000000 --- a/lua/util.lua +++ /dev/null @@ -1,246 +0,0 @@ -local M = {} - -M.root_patterns = { ".git", "lua", "package.json", "mvnw", "gradlew", "pom.xml", "build.gradle", "release", ".project" } - -M.augroup = function(name) - return vim.api.nvim_create_augroup("tlh_" .. name, { clear = true }) -end --- ───────────────────────────────────────────────────────────────── -M.has = function(plugin) - return require("lazy.core.config").plugins[plugin] ~= nil -end --- ───────────────────────────────────────────────────────────────── -function M.get_clients(...) - local fn = vim.lsp.get_clients or vim.lsp.get_active_clients - return fn(...) -end --- ───────────────────────────────────────────────────────────────── ---- @param on_attach fun(client, buffer) -M.on_attach = function(on_attach) - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local buffer = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) - on_attach(client, buffer) - end, - }) -end --- ───────────────────────────────────────────────────────────────── -M.get_highlight_value = function(group) - local found, hl = pcall(vim.api.nvim_get_hl_by_name, group, true) - if not found then - return {} - end - local hl_config = {} - for key, value in pairs(hl) do - _, hl_config[key] = pcall(string.format, "#%02x", value) - end - return hl_config -end --- ───────────────────────────────────────────────────────────────── --- return plugin opts ----@param name string -function M.opts(name) - local plugin = require("lazy.core.config").plugins[name] - if not plugin then - return {} - end - local Plugin = require("lazy.core.plugin") - return Plugin.values(plugin, "opts", false) -end - --- returns the root directory based on: --- * lsp workspace folders --- * lsp root_dir --- * root pattern of filename of the current buffer --- * root pattern of cwd ----@return string -M.get_root = function() - ---@type string? - local path = vim.api.nvim_buf_get_name(0) - path = path ~= "" and vim.loop.fs_realpath(path) or nil - ---@type string[] - local roots = {} - if path then - for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do - local workspace = client.config.workspace_folders - local paths = workspace - and vim.tbl_map(function(ws) - return vim.uri_to_fname(ws.uri) - end, workspace) - or client.config.root_dir and { client.config.root_dir } - or {} - for _, p in ipairs(paths) do - local r = vim.loop.fs_realpath(p) - if path:find(r, 1, true) then - roots[#roots + 1] = r - end - end - end - end - table.sort(roots, function(a, b) - return #a > #b - end) - ---@type string? - local root = roots[1] - if not root then - path = path and vim.fs.dirname(path) or vim.loop.cwd() - ---@type string? - root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1] - root = root and vim.fs.dirname(root) or vim.loop.cwd() - end - ---@cast root string - return root -end - -M.set_root = function(dir) - vim.api.nvim_set_current_dir(dir) -end - ----@param type "ivy" | "dropdown" | "cursor" | nil -M.telescope_theme = function(type) - if type == nil then - return { - borderchars = M.generate_borderchars("thick"), - layout_config = { - width = 80, - height = 0.5, - }, - } - end - return require("telescope.themes")["get_" .. type]({ - cwd = M.get_root(), - borderchars = M.generate_borderchars("thick", nil, { top = "█", top_left = "█", top_right = "█" }), - }) -end --- ───────────────────────────────────────────────────────────────── ----@param builtin "find_files" | "live_grep" | "buffers" ----@param type "ivy" | "dropdown" | "cursor" | nil -M.telescope = function(builtin, type, opts) - local params = { builtin = builtin, type = type, opts = opts } - return function() - builtin = params.builtin - type = params.type - opts = params.opts - opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}) - local theme - if vim.tbl_contains({ "ivy", "dropdown", "cursor" }, type) then - theme = M.telescope_theme(type) - else - theme = opts - end - require("telescope.builtin")[builtin](theme) - end -end --- ───────────────────────────────────────────────────────────────── ----@param name "autocmds" | "options" | "keymaps" -M.load = function(name) - local Util = require("lazy.core.util") - -- always load lazyvim, then user file - local mod = "core." .. name - Util.try(function() - require(mod) - end, { - msg = "Failed loading " .. mod, - on_error = function(msg) - local modpath = require("lazy.core.cache").find(mod) - if modpath then - Util.error(msg) - end - end, - }) -end --- ───────────────────────────────────────────────────────────────── -M.on_very_lazy = function(fn) - vim.api.nvim_create_autocmd("User", { - pattern = "VeryLazy", - callback = function() - fn() - end, - }) -end --- ───────────────────────────────────────────────────────────────── -M.capabilities = function(ext) - return vim.tbl_deep_extend( - "force", - {}, - ext or {}, - require("cmp_nvim_lsp").default_capabilities(), - { textDocument = { foldingRange = { dynamicRegistration = false, lineFoldingOnly = true } } } - ) -end --- ───────────────────────────────────────────────────────────────── -M.notify = function(msg, level, opts) - opts = opts or {} - level = vim.log.levels[level:upper()] - if type(msg) == "table" then - msg = table.concat(msg, "\n") - end - local nopts = { title = "NeoVim" } - if opts.once then - return vim.schedule(function() - vim.notify_once(msg, level, nopts) - end) - end - vim.schedule(function() - vim.notify(msg, level, nopts) - end) -end --- ───────────────────────────────────────────────────────────────── ---- @param type "thin" | "thick" | "empty" | nil ---- @param order "t-r-b-l-tl-tr-br-bl" | "tl-t-tr-r-bl-b-br-l" | nil ---- @param opts BorderIcons | nil -M.generate_borderchars = function(type, order, opts) - if order == nil then - order = "t-r-b-l-tl-tr-br-bl" - end - local border_icons = require("core.icons").borders - --- @type BorderIcons - local border = vim.tbl_deep_extend("force", border_icons[type or "empty"], opts or {}) - - local borderchars = {} - - local extractDirections = (function() - local index = 1 - return function() - if index == nil then - return nil - end - -- Find the next occurence of `char` - local nextIndex = string.find(order, "-", index) - -- Extract the first direction - local direction = string.sub(order, index, nextIndex and nextIndex - 1) - -- Update the index to nextIndex - ---@diagnostic disable-next-line: cast-local-type - index = nextIndex and nextIndex + 1 or nil - return direction - end - end)() - - local mappings = { - t = "top", - r = "right", - b = "bottom", - l = "left", - tl = "top_left", - tr = "top_right", - br = "bottom_right", - bl = "bottom_left", - } - local direction = extractDirections() - while direction do - if mappings[direction] == nil then - M.notify(string.format("Invalid direction '%s'", direction), "error") - end - borderchars[#borderchars + 1] = border[mappings[direction]] - direction = extractDirections() - end - - if #borderchars ~= 8 then - M.notify(string.format("Invalid order '%s'", order), "error") - end - - return borderchars -end - -return M diff --git a/lua/utils/cmd.lua b/lua/utils/cmd.lua new file mode 100644 index 0000000..260fd5c --- /dev/null +++ b/lua/utils/cmd.lua @@ -0,0 +1,33 @@ +local job = require("plenary.job") + +---@class utils.cmd +local M = {} + +local function split_cmd(command) + local cmd = {} + for word in command:gmatch("%S+") do + table.insert(cmd, word) + end + return cmd +end + +function M.execute(command, callback) + local cmd = split_cmd(command) + job + :new({ + command = cmd[1], + args = vim.list_slice(cmd, 2, #cmd), + on_exit = function(j, exit_code) + if exit_code ~= 0 then + return + end + local value = j:result() + if value ~= nil and value ~= "" then + callback(value) + end + end, + }) + :start() +end + +return M diff --git a/lua/utils/init.lua b/lua/utils/init.lua new file mode 100644 index 0000000..d122059 --- /dev/null +++ b/lua/utils/init.lua @@ -0,0 +1,109 @@ +local Profile = require("profile") + +---@class Util +---@field root utils.root +---@field telescope utils.telescope +---@field theme utils.theme +---@field plugin utils.plugin +---@field lualine utils.lualine +---@field cmd utils.cmd +---@field lsp utils.lsp +---@field string utils.string +---@field table utils.table +local M = {} + +setmetatable(M, { + __index = function(_, k) + local mod = require("utils." .. k) + return mod + end, +}) + +---@param group string The name of the group +function M.augroup(group) + return vim.api.nvim_create_augroup(Profile.name .. "-" .. group, { clear = true }) +end + +---@param fn fun() A callback +function M.on_very_lazy(fn) + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + fn() + end, + }) +end + +---A Notifier +--- @param msg string +--- @param level "DEBUG" |"INFO" | "WARN" | "ERROR" | number +--- @param opts? table +function M.notify(msg, level, opts) + opts = opts or {} + level = vim.log.levels[level:upper()] + if type(msg) == "table" then + msg = table.concat(msg, "\n") + end + local nopts = { title = "Nvim" } + if opts.once then + return vim.schedule(function() + vim.notify_once(msg, level, nopts) + end) + end + vim.schedule(function() + vim.notify(msg, level, nopts) + end) +end + +function M.error(msg) + M.notify(msg, "ERROR", { title = Profile.name, timeout = 1000 }) +end + +---@param fn fun() The function to try +---@param opts {msg?: string, on_error?: fun(err: string)} +function M.try(fn, opts) + local ok, result = xpcall(fn, function(error) + local msg = (opts and opts.msg or "") .. (opts and opts.msg and "\n\n" or "") .. error + local handler = opts and opts.on_error or M.error + handler(msg) + return error + end) + return ok and result or nil +end + +--- Reference: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/init.lua#L149 +-- Wrapper around vim.keymap.set that will +-- not create a keymap if a lazy key handler exists. +-- It will also set `silent` to true by default. +function M.safe_keymap_set(mode, lhs, rhs, opts) + local keys = require("lazy.core.handler").handlers.keys + local modes = type(mode) == "string" and { mode } or mode + + ---@param m string + modes = vim.tbl_filter(function(m) + return not (keys.have and keys:have(lhs, m)) + end, modes) + + -- do not create the keymap if a lazy keys handler exists + if #modes > 0 then + opts = opts or {} + opts.silent = opts.silent ~= false + if opts.remap and not vim.g.vscode then + ---@diagnostic disable-next-line: no-unknown + opts.remap = nil + end + vim.keymap.set(modes, lhs, rhs, opts) + end +end + +local executed = false +--- Ensures that the given callback is only executed once +---@param callback fun() +function M.once(callback) + if not executed then + callback() + executed = true + end +end + +return M diff --git a/lua/utils/lsp.lua b/lua/utils/lsp.lua new file mode 100644 index 0000000..3c1dfe2 --- /dev/null +++ b/lua/utils/lsp.lua @@ -0,0 +1,15 @@ +---@class utils.lsp +local M = {} + +--- @param on_attach fun(client, bufnr) +function M.on_attach(on_attach) + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local bufnr = args.buf ---@type number + local client = vim.lsp.get_client_by_id(args.data.client_id) + on_attach(client, bufnr) + end, + }) +end + +return M diff --git a/lua/utils/lualine.lua b/lua/utils/lualine.lua new file mode 100644 index 0000000..732afa6 --- /dev/null +++ b/lua/utils/lualine.lua @@ -0,0 +1,100 @@ +local Utils = require("utils") + +---@class utils.lualine +local M = {} + +local context = {} +local counter = 0 +---@param key string The key of the highlight group +function M.get_hl_gr(key) + if context[key] ~= nil then + return context[key] + end + local hl_gr = ("SL" .. counter):gsub("%s+", "") + context[key] = hl_gr + counter = counter + 1 + return hl_gr +end + +---This function applies a specified highlight group to a given text string and optionally applies a different highlight group after the text. +---@param text string The text to highlight +---@param hl_cur string The highlight group to use +---@param hl_after? string The highlight group to use after the text +function M.hl_str(text, hl_cur, hl_after) + if hl_after == nil then + return "%#" .. hl_cur .. "#" .. text .. "%*" + end + return "%#" .. hl_cur .. "#" .. text .. "%*" .. "%#" .. hl_after .. "#" +end + +---Truncates a text string to a specified minimum width and adds an ellipsis if necessary. +---@param text string The text to truncate +---@param min_width number The minimum width +function M.truncate(text, min_width) + if string.len(text) > min_width then + return string.sub(text, 1, min_width) .. "…" + end + return text +end + +---@param type LualineSeparatorType +---@return HexColor +function M.get_component_bg(type) + local bg = "#555555" + if type == "fill" then + bg = Utils.theme.highlight("Pmenu").bg or bg + elseif type == "thin" then + bg = Utils.theme.highlight("lualine_c_normal").bg or bg + end + return bg +end + +---@param config LualineOptions +---@param texts {text: string, color: HexColor}[] Texts to display +---@param type LualineSeparatorType Type of the component (fill, thin) +---@param bg? HexColor Background of a component +---@param text_sep? string Separator between texts +function M.build_component(config, texts, type, bg, text_sep) + local BAR_BG = Utils.theme.highlight("lualine_c_normal").bg + local SEP_GROUP = "SLSeparator" + bg = bg or M.get_component_bg(type) + + if type == "fill" then + vim.api.nvim_set_hl(0, SEP_GROUP, { fg = bg, bg = BAR_BG }) + elseif type == "thin" then + vim.api.nvim_set_hl(0, SEP_GROUP, { fg = Utils.theme.highlight("Pmenu").bg, bg = BAR_BG }) + end + + local merged_text = table.concat( + vim.tbl_map(function(text) + local hl_gr = M.get_hl_gr(text.text) + if config.float then + if type == "fill" then + vim.api.nvim_set_hl(0, hl_gr, { fg = text.color, bg = bg }) + else + vim.api.nvim_set_hl(0, hl_gr, { fg = text.color, bg = BAR_BG }) + end + else + vim.api.nvim_set_hl(0, hl_gr, { fg = text.color, bg = BAR_BG }) + end + return M.hl_str(text.text, hl_gr, hl_gr) + end, texts), + text_sep or "" + ) + if config.float then + return M.hl_str(config.separator[type].left, SEP_GROUP) + .. merged_text + .. M.hl_str(config.separator[type].right, SEP_GROUP, SEP_GROUP) + else + return merged_text + end +end + +---Hide the component if the current window width is less than the specified minimum width +---@param width? number The minimum width -- Default: 85 +function M.hide_width(width) + width = width or 85 + return vim.fn.winwidth(0) > width +end + +return M diff --git a/lua/utils/plugin.lua b/lua/utils/plugin.lua new file mode 100644 index 0000000..405b87f --- /dev/null +++ b/lua/utils/plugin.lua @@ -0,0 +1,21 @@ +---@class utils.plugin +local M = {} + +---Check if a plugin is installed +---@param plugin string The name of the plugin. Example `noice.nvim` +function M.has(plugin) + return require("lazy.core.config").plugins[plugin] ~= nil +end + +---Get options of a plugin +---@param name string The name of the plugin. Example `noice.nvim` +function M.opts(name) + local plugin = require("lazy.core.config").plugins[name] + if not plugin then + return {} + end + local Plugin = require("lazy.core.plugin") + return Plugin.values(plugin, "opts", false) +end + +return M diff --git a/lua/utils/root.lua b/lua/utils/root.lua new file mode 100644 index 0000000..a469c5e --- /dev/null +++ b/lua/utils/root.lua @@ -0,0 +1,51 @@ +---@class utils.root +local M = setmetatable({}, { + __call = function(m) + return m.get() + end, +}) + +M.root_patterns = { ".git", "lua", "package.json", "mvnw", "gradlew", "pom.xml", "build.gradle", "release", ".project" } + +-- returns the root directory based on: +-- * lsp workspace folders +-- * lsp root_dir +-- * root pattern of filename of the current buffer +-- * root pattern of cwd +---@return string +function M.get() + ---@type string? + local path = vim.api.nvim_buf_get_name(0) + path = path ~= "" and vim.loop.fs_realpath(path) or nil + ---@type string[] + local roots = {} + if path then + for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do + local workspace = client.config.workspace_folders + local paths = workspace and vim.tbl_map(function(ws) + return vim.uri_to_fname(ws.uri) + end, workspace) or client.config.root_dir and { client.config.root_dir } or {} + for _, p in ipairs(paths) do + local r = vim.loop.fs_realpath(p) + if path:find(r, 1, true) then + roots[#roots + 1] = r + end + end + end + end + table.sort(roots, function(a, b) + return #a > #b + end) + ---@type string? + local root = roots[1] + if not root then + path = path and vim.fs.dirname(path) or vim.loop.cwd() + ---@type string? + root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1] + root = root and vim.fs.dirname(root) or vim.loop.cwd() + end + ---@cast root string + return root +end + +return M diff --git a/lua/utils/string.lua b/lua/utils/string.lua new file mode 100644 index 0000000..8f944b3 --- /dev/null +++ b/lua/utils/string.lua @@ -0,0 +1,8 @@ +---@class utils.string +local M = {} + +function M.capitalize(s) + return (s:gsub("^%l", string.upper)) +end + +return M diff --git a/lua/utils/table.lua b/lua/utils/table.lua new file mode 100644 index 0000000..a5d75e7 --- /dev/null +++ b/lua/utils/table.lua @@ -0,0 +1,16 @@ +---@class utils.table +local M = {} + +---Checks if any value in the collection passes the predicate +---@param collection table The collection to iterate over +---@param predicate function The predicate to check +function M.any(collection, predicate) + for _, value in ipairs(collection) do + if predicate(value) then + return true + end + end + return false +end + +return M diff --git a/lua/utils/telescope.lua b/lua/utils/telescope.lua new file mode 100644 index 0000000..c2c067c --- /dev/null +++ b/lua/utils/telescope.lua @@ -0,0 +1,103 @@ +local Utils = require("utils") +local Icons = require("core.icons") + +---@class utils.telescope +local M = setmetatable({}, { + __call = function(m, ...) + return m.telescope(...) + end, +}) + +---@param builtin "find_files" | "live_grep" | "buffers" +---@param type? "ivy" | "dropdown" | "cursor" +function M.telescope(builtin, type, opts) + return function() + builtin = builtin + type = type + opts = opts + opts = vim.tbl_deep_extend("force", { cwd = Utils.root() }, opts or {}) + local theme + if vim.tbl_contains({ "ivy", "dropdown", "cursor" }, type) then + theme = M.theme(type) + else + theme = opts + end + require("telescope.builtin")[builtin](theme) + end +end + +---@param type? "ivy" | "dropdown" | "cursor" +--- @param border_style? BorderStyle +function M.theme(type, border_style) + if type == nil then + return { + borderchars = M.borderchars(border_style), + layout_config = { + width = 80, + height = 0.5, + }, + } + end + local theme = require("telescope.themes")["get_" .. type]({ + cwd = Utils.root(), + borderchars = M.borderchars(border_style, nil, { top = "█", top_left = "█", top_right = "█" }), + }) + return theme +end + +---Get the border characters for the given border style +--- @param border_style? BorderStyle +--- @param order? BorderOrder +--- @param opts? BorderIcons +function M.borderchars(border_style, order, opts) + order = order or "t-r-b-l-tl-tr-br-bl" + local border_icons = Icons.borders + --- @type BorderIcons + local border = vim.tbl_deep_extend("force", border_icons[border_style or "empty"], opts or {}) + + local borderchars = {} + + local extract_directions = (function() + ---@type number | nil + local index = 1 + return function() + if index == nil then + return nil + end + -- Find the next occurence of `char` + local nextIndex = string.find(order, "-", index) + -- Extract the first direction + local direction = string.sub(order, index, nextIndex and nextIndex - 1) + -- Update the index to nextIndex + index = nextIndex and nextIndex + 1 or nil + return direction + end + end)() + + local mappings = { + t = "top", + r = "right", + b = "bottom", + l = "left", + tl = "top_left", + tr = "top_right", + br = "bottom_right", + bl = "bottom_left", + } + local direction = extract_directions() + while direction do + if mappings[direction] == nil then + Utils.notify(string.format("Invalid direction '%s'", direction), "ERROR") + end + borderchars[#borderchars + 1] = border[mappings[direction]] + direction = extract_directions() + end + + if #borderchars ~= 8 then + Utils.notify(string.format("Invalid order '%s'", order), "ERROR") + end + + return borderchars +end + +return M diff --git a/lua/utils/theme.lua b/lua/utils/theme.lua new file mode 100644 index 0000000..fcaea4c --- /dev/null +++ b/lua/utils/theme.lua @@ -0,0 +1,35 @@ +---@class utils.theme +local M = {} + +---@alias HexColor string + +---@class HighlightGroupValue +---@field fg? HexColor +---@field bg? HexColor + +---Get the color of a highlight group +---@param group string The name of the highlight group +---@return HighlightGroupValue +function M.highlight(group) + ---@param name string + local function get_hl_by_name(name) + local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) + or vim.api.nvim_get_hl_by_name(name, true) + local fg = hl and (hl.fg or hl.foreground) + local bg = hl and (hl.bg or hl.background) + return { fg = fg, bg = bg } + end + local success, hl = pcall(get_hl_by_name, group) + if not success then + -- stylua: ignore + return setmetatable({}, { __index = function() return nil end, }) + end + + return setmetatable({}, { + __index = function(_, key) + return rawget(hl, key) and string.format("#%06x", rawget(hl, key)) or nil + end, + }) +end + +return M diff --git a/ui.lua b/ui.lua new file mode 100644 index 0000000..d36d22e --- /dev/null +++ b/ui.lua @@ -0,0 +1,509 @@ +local Icons = require("core").icons +local Logos = require("core") +local Utils = require("utils") + +return { + -- UI components + { "MunifTanjim/nui.nvim", lazy = true }, + + -- icons + { "nvim-tree/nvim-web-devicons", lazy = true }, + + { + "rcarriga/nvim-notify", + keys = { + { + "n", + function() + require("notify").dismiss({ silent = true, pending = true }) + end, + desc = "Delete all Notifications", + }, + }, + opts = { + icons = { + ERROR = Icons.diagnostics.error .. " ", + INFO = Icons.diagnostics.info .. " ", + WARN = Icons.diagnostics.warn .. " ", + }, + timeout = 3000, + max_height = function() + return math.floor(vim.o.lines * 0.75) + end, + max_width = function() + return math.floor(vim.o.columns * 0.75) + end, + }, + init = function() + if not Utils.plugin.has("noice.nvim") then + Utils.on_very_lazy(function() + vim.notify = require("notify") + end) + end + end, + }, + + { + "nvim-lualine/lualine.nvim", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + opts = function() + local lualine_require = require("lualine_require") + lualine_require.require = require + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") + return { + float = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), + colorful = true, + } + end, + config = function(_, opts) + local lualine = require("features.lualine") + lualine.setup(opts) + lualine.load() + end, + }, + + { + "akinsho/bufferline.nvim", + event = { "BufReadPost", "BufNewFile" }, + keys = { + { "", "BufferLineGoToBuffer 1", desc = "Go to buffer 1" }, + { "", "BufferLineGoToBuffer 2", desc = "Go to buffer 2" }, + { "", "BufferLineGoToBuffer 3", desc = "Go to buffer 3" }, + { "", "BufferLineGoToBuffer 4", desc = "Go to buffer 4" }, + { "", "BufferLineGoToBuffer 5", desc = "Go to buffer 5" }, + { "", "BufferLineGoToBuffer 6", desc = "Go to buffer 6" }, + { "", "BufferLineGoToBuffer 7", desc = "Go to buffer 7" }, + { "", "BufferLineGoToBuffer 8", desc = "Go to buffer 8" }, + { "", "BufferLineGoToBuffer 9", desc = "Go to buffer 9" }, + { "", "BufferLineCycleNext", desc = "Next buffer" }, + { "", "BufferLineCyclePrev", desc = "Previous buffer" }, + { "", "BufferLineMoveNext", desc = "Move buffer right" }, + { "", "BufferLineMovePrev", desc = "Move buffer left" }, + }, + opts = function() + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") + return { + options = { + diagnostics = "nvim_lsp", -- | "nvim_lsp" | "coc", + -- separator_style = "", -- | "thick" | "thin" | "slope" | { 'any', 'any' }, + separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' }, + -- separator_style = "slant", -- | "thick" | "thin" | { 'any', 'any' }, + indicator = { + -- icon = " ", + -- style = 'icon', + style = "underline", + }, + close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + diagnostics_indicator = function(count, _, _, _) + if count > 9 then + return "9+" + end + return tostring(count) + end, + offsets = { + { + filetype = "neo-tree", + text = "EXPLORER", + text_align = "center", + separator = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), -- set to `true` if clear background of neo-tree + }, + { + filetype = "NvimTree", + text = "EXPLORER", + text_align = "center", + separator = vim.tbl_contains(monokai_opts.background_clear or {}, "nvim-tree"), -- set to `true` if clear background of neo-tree + }, + }, + hover = { + enabled = true, + delay = 0, + reveal = { "close" }, + }, + }, + } + end, + }, + + { + "utilyre/barbecue.nvim", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + dependencies = { + "SmiteshP/nvim-navic", + "nvim-tree/nvim-web-devicons", + }, + opts = { + attach_navic = false, + theme = "auto", + include_buftypes = { "" }, + exclude_filetypes = { "gitcommit", "Trouble", "toggleterm" }, + show_modified = false, + kinds = Icons.kinds, + }, + }, + + { + "nvimdev/dashboard-nvim", + event = "VimEnter", + dependencies = { { "nvim-tree/nvim-web-devicons" } }, + keys = { { "0", "Dashboard", desc = "Dashboard" } }, + opts = function() + local opts = { + theme = "doom", + hide = { + statusline = 0, + tabline = 0, + winbar = 0, + }, + config = { + header = Logos.logos.random(), + center = { + { + action = "Telescope oldfiles", + desc = "Recent Files", + key = "r", + icon = " ", + icon_hl = "DashboardRecent", + key_hl = "DashboardRecent", + }, + { + action = "lua require('persistence').load({last = true})", + desc = "Last Session", + key = "s", + icon = " ", + icon_hl = "DashboardSession", + key_hl = "DashboardSession", + }, + { + icon = " ", + icon_hl = "DashboardConfiguration", + desc = "Configuration", + key = "i", + key_hl = "DashboardConfiguration", + action = "edit $MYVIMRC", + }, + { + icon = "󰤄 ", + icon_hl = "DashboardLazy", + desc = "Lazy", + key = "l", + key_hl = "DashboardLazy", + action = "Lazy", + }, + { + icon = " ", + icon_hl = "DashboardServer", + desc = "Mason", + key = "m", + key_hl = "DashboardServer", + action = "Mason", + }, + { + icon = " ", + icon_hl = "DashboardQuit", + desc = "Quit Neovim", + key = "q", + key_hl = "DashboardQuit", + action = "qa", + }, + }, + footer = function() + ---@diagnostic disable-next-line: different-requires + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { + "⚡  eovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms", + } + end, + }, + } + for _, button in pairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 45 - #button.desc) + button.icon = button.icon .. string.rep(" ", 5 - #button.icon) + end + + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + pattern = "DashboardLoaded", + callback = function() + ---@diagnostic disable-next-line: different-requires + require("lazy").show() + end, + }) + end + return opts + end, + }, + + { + "petertriho/nvim-scrollbar", + event = { "BufReadPost", "BufNewFile" }, + opts = { + set_highlights = false, + excluded_filetypes = { + "prompt", + "TelescopePrompt", + "noice", + "neo-tree", + "dashboard", + "alpha", + "lazy", + "mason", + "DressingInput", + "", + }, + handlers = { + gitsigns = true, + }, + }, + }, + + { + "anuvyklack/windows.nvim", + event = "WinNew", + dependencies = { + { "anuvyklack/middleclass" }, + { "anuvyklack/animation.nvim", enabled = true }, + }, + opts = { + animation = { enable = true, duration = 150, fps = 60 }, + autowidth = { enable = true }, + }, + keys = { { "m", "WindowsMaximize", desc = "Zoom window" } }, + init = function() + vim.o.winwidth = 30 + vim.o.winminwidth = 30 + vim.o.equalalways = true + end, + }, + + -- better vim.ui + { + "stevearc/dressing.nvim", + event = { "BufReadPost", "BufNewFile" }, + opts = function() + local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") + local border_style = vim.tbl_contains(monokai_opts.background_clear or {}, "float_win") and "rounded" or "thick" + return { + input = { + border = Utils.telescope.borderchars(border_style, "tl-t-tr-r-br-b-bl-l"), + win_options = { winblend = 0 }, + }, + select = vim.tbl_contains(monokai_opts.background_clear or {}, "telescope") and {} or { + telescope = Utils.telescope.theme("cursor", "thick"), + }, + } + end, + init = function() + vim.ui.select = function(...) + ---@diagnostic disable-next-line: different-requires + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.select(...) + end + vim.ui.input = function(...) + ---@diagnostic disable-next-line: different-requires + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.input(...) + end + end, + }, + + { + "echasnovski/mini.hipatterns", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + opts = function() + local hi = require("mini.hipatterns") + return { + highlighters = { + -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE' + fixme = { pattern = "%f[%w]()FIXME()%f[%W]", group = "MiniHipatternsFixme" }, + hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, + todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, + note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" }, + -- Highlight hex color strings (`#rrggbb`) using that color + hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }), + }, + } + end, + }, + + { + "kosayoda/nvim-lightbulb", + opts = { + sign = { + enabled = true, + -- Priority of the gutter sign + priority = 20, + }, + status_text = { + enabled = true, + -- Text to provide when code actions are available + text = "status_text", + -- Text to provide when no actions are available + text_unavailable = "", + }, + autocmd = { + enabled = true, + -- see :help autocmd-pattern + pattern = { "*" }, + -- see :help autocmd-events + events = { "CursorHold", "CursorHoldI", "LspAttach" }, + }, + }, + }, + + -- noicer ui + { + "folke/noice.nvim", + event = "VeryLazy", + opts = { + cmdline = { + enabled = true, + view = "cmdline", + format = { + cmdline = { icon = "  " }, + search_down = { icon = " 🔍 󰄼" }, + search_up = { icon = " 🔍 " }, + help = { icon = " 󰋖" }, + lua = { icon = "  " }, + }, + }, + lsp = { + progress = { + enabled = true, + format = "lsp_progress", + format_done = "lsp_progress_done", + view = "mini", + }, + hover = { enabled = false }, + signature = { enabled = false }, + -- 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, + }, + }, + routes = { + { + filter = { + event = "msg_show", + any = { + { find = "%d+L, %d+B" }, + { find = "No active Snippet" }, + { find = "; after #%d+" }, + { find = "; before #%d+" }, + { find = "Hunk" }, + }, + }, + view = "mini", + }, + { + filter = { + event = "notify", + any = { + { find = "No information available" }, + }, + }, + }, + }, + }, + }, + + { + "lukas-reineke/indent-blankline.nvim", + event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + opts = function() + local hooks = require("ibl.hooks") + hooks.register(hooks.type.SCOPE_ACTIVE, function(bufnr) + return vim.api.nvim_buf_line_count(bufnr) < 2000 + end) + + local highlight = { + "RainbowDelimiterRed", + "RainbowDelimiterYellow", + "RainbowDelimiterBlue", + "RainbowDelimiterOrange", + "RainbowDelimiterGreen", + "RainbowDelimiterViolet", + "RainbowDelimiterCyan", + } + return { + debounce = 200, + indent = { + char = "▏", + tab_char = "▏", + -- highlight = "IndentBlanklineChar", + -- highlight = highlight, + }, + scope = { + injected_languages = true, + highlight = highlight, + enabled = true, + show_start = true, + show_end = false, + char = "▏", + -- include = { + -- node_type = { ["*"] = { "*" } }, + -- }, + -- exclude = { + -- node_type = { ["*"] = { "source_file", "program" }, python = { "module" }, lua = { "chunk" } }, + -- }, + }, + exclude = { + filetypes = { + "help", + "startify", + "dashboard", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", + "alpha", + "neo-tree", + }, + buftypes = { + "terminal", + "nofile", + }, + }, + } + end, + main = "ibl", + }, + { + "akinsho/toggleterm.nvim", + event = { "BufReadPost", "BufNewFile" }, + opts = { + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = "1", + start_in_insert = true, + direction = "float", + insert_mappings = true, + persist_size = true, + close_on_exit = false, + shell = "/run/current-system/sw/bin/zsh", + autochdir = false, + float_opts = { + border = "single", + winblend = 3, + width = 85, + height = 55, + highlights = { + border = "Normal", + background = "Normal", + }, + }, + winbar = { + enabled = false, + name_formatter = function(term) + return term.name + end, + }, + }, + }, +}