From 67c224a398201c72a03dbc832b7952825d16a5f9 Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Tue, 2 Jul 2024 23:52:43 +0200 Subject: [PATCH] Setup --- Readme.md | 36 +++++++ init.lua | 1 + lua/core/editor.lua | 8 ++ lua/core/init.lua | 3 + lua/core/keymap.lua | 5 + lua/core/package_manager.lua | 19 ++++ lua/editor/auto_brackets.lua | 4 + lua/editor/dashboard.lua | 32 ++++++ lua/editor/debugging.lua | 115 ++++++++++++++++++++ lua/editor/file_tree.lua | 81 ++++++++++++++ lua/editor/highlighting.lua | 14 +++ lua/editor/key_list.lua | 8 ++ lua/editor/language_server.lua | 118 +++++++++++++++++++++ lua/editor/llm.lua | 57 ++++++++++ lua/editor/search.lua | 68 ++++++++++++ lua/editor/snippets.lua | 76 +++++++++++++ lua/editor/status_bar.lua | 77 ++++++++++++++ lua/editor/terminal.lua | 30 ++++++ lua/editor/theme.lua | 9 ++ lua/temp/status_bar_plugin.lua | 65 ++++++++++++ lua/toolchain/config/actions.lua | 5 + lua/toolchain/config/debugger.lua | 4 + lua/toolchain/config/diagnostics.lua | 10 ++ lua/toolchain/config/formatter.lua | 5 + lua/toolchain/config/init.lua | 10 ++ lua/toolchain/config/language_server.lua | 16 +++ lua/toolchain/config/plugins.lua | 9 ++ lua/toolchain/config/requirements.lua | 17 +++ lua/toolchain/database/actions.lua | 5 + lua/toolchain/database/debugger.lua | 4 + lua/toolchain/database/diagnostics.lua | 5 + lua/toolchain/database/formatter.lua | 5 + lua/toolchain/database/init.lua | 10 ++ lua/toolchain/database/language_server.lua | 10 ++ lua/toolchain/database/plugins.lua | 1 + lua/toolchain/database/requirements.lua | 14 +++ lua/toolchain/frontend/actions.lua | 5 + lua/toolchain/frontend/debugger.lua | 4 + lua/toolchain/frontend/diagnostics.lua | 5 + lua/toolchain/frontend/formatter.lua | 5 + lua/toolchain/frontend/init.lua | 10 ++ lua/toolchain/frontend/language_server.lua | 12 +++ lua/toolchain/frontend/plugins.lua | 1 + lua/toolchain/frontend/requirements.lua | 16 +++ lua/toolchain/generic/actions.lua | 9 ++ lua/toolchain/generic/debugger.lua | 4 + lua/toolchain/generic/diagnostics.lua | 5 + lua/toolchain/generic/formatter.lua | 5 + lua/toolchain/generic/init.lua | 10 ++ lua/toolchain/generic/language_server.lua | 5 + lua/toolchain/generic/plugins.lua | 1 + lua/toolchain/generic/requirements.lua | 12 +++ lua/toolchain/git/actions.lua | 5 + lua/toolchain/git/debugger.lua | 4 + lua/toolchain/git/diagnostics.lua | 5 + lua/toolchain/git/formatter.lua | 5 + lua/toolchain/git/init.lua | 10 ++ lua/toolchain/git/language_server.lua | 5 + lua/toolchain/git/plugins.lua | 38 +++++++ lua/toolchain/git/requirements.lua | 18 ++++ lua/toolchain/go/actions.lua | 10 ++ lua/toolchain/go/debugger.lua | 18 ++++ lua/toolchain/go/diagnostics.lua | 10 ++ lua/toolchain/go/formatter.lua | 9 ++ lua/toolchain/go/init.lua | 10 ++ lua/toolchain/go/language_server.lua | 9 ++ lua/toolchain/go/plugins.lua | 1 + lua/toolchain/go/requirements.lua | 17 +++ lua/toolchain/lua/actions.lua | 5 + lua/toolchain/lua/debugger.lua | 4 + lua/toolchain/lua/diagnostics.lua | 9 ++ lua/toolchain/lua/formatter.lua | 9 ++ lua/toolchain/lua/init.lua | 10 ++ lua/toolchain/lua/language_server.lua | 18 ++++ lua/toolchain/lua/plugins.lua | 1 + lua/toolchain/lua/requirements.lua | 15 +++ lua/toolchain/php/actions.lua | 5 + lua/toolchain/php/debugger.lua | 4 + lua/toolchain/php/diagnostics.lua | 11 ++ lua/toolchain/php/formatter.lua | 12 +++ lua/toolchain/php/init.lua | 10 ++ lua/toolchain/php/language_server.lua | 13 +++ lua/toolchain/php/plugins.lua | 1 + lua/toolchain/php/requirements.lua | 16 +++ lua/toolchain/scripts/actions.lua | 5 + lua/toolchain/scripts/debugger.lua | 4 + lua/toolchain/scripts/diagnostics.lua | 11 ++ lua/toolchain/scripts/formatter.lua | 10 ++ lua/toolchain/scripts/init.lua | 10 ++ lua/toolchain/scripts/language_server.lua | 10 ++ lua/toolchain/scripts/plugins.lua | 1 + lua/toolchain/scripts/requirements.lua | 17 +++ lua/toolchain/text/actions.lua | 9 ++ lua/toolchain/text/debugger.lua | 4 + lua/toolchain/text/diagnostics.lua | 11 ++ lua/toolchain/text/formatter.lua | 9 ++ lua/toolchain/text/init.lua | 10 ++ lua/toolchain/text/language_server.lua | 10 ++ lua/toolchain/text/plugins.lua | 36 +++++++ lua/toolchain/text/requirements.lua | 14 +++ lua/toolchain/web/actions.lua | 5 + lua/toolchain/web/debugger.lua | 4 + lua/toolchain/web/diagnostics.lua | 9 ++ lua/toolchain/web/formatter.lua | 11 ++ lua/toolchain/web/init.lua | 10 ++ lua/toolchain/web/language_server.lua | 20 ++++ lua/toolchain/web/plugins.lua | 1 + lua/toolchain/web/requirements.lua | 18 ++++ lua/util/finder.lua | 112 +++++++++++++++++++ lua/util/toolchain.lua | 72 +++++++++++++ stylua.toml | 7 ++ 111 files changed, 1822 insertions(+) create mode 100644 Readme.md create mode 100644 init.lua create mode 100644 lua/core/editor.lua create mode 100644 lua/core/init.lua create mode 100644 lua/core/keymap.lua create mode 100644 lua/core/package_manager.lua create mode 100644 lua/editor/auto_brackets.lua create mode 100644 lua/editor/dashboard.lua create mode 100644 lua/editor/debugging.lua create mode 100644 lua/editor/file_tree.lua create mode 100644 lua/editor/highlighting.lua create mode 100644 lua/editor/key_list.lua create mode 100644 lua/editor/language_server.lua create mode 100644 lua/editor/llm.lua create mode 100644 lua/editor/search.lua create mode 100644 lua/editor/snippets.lua create mode 100644 lua/editor/status_bar.lua create mode 100644 lua/editor/terminal.lua create mode 100644 lua/editor/theme.lua create mode 100644 lua/temp/status_bar_plugin.lua create mode 100644 lua/toolchain/config/actions.lua create mode 100644 lua/toolchain/config/debugger.lua create mode 100644 lua/toolchain/config/diagnostics.lua create mode 100644 lua/toolchain/config/formatter.lua create mode 100644 lua/toolchain/config/init.lua create mode 100644 lua/toolchain/config/language_server.lua create mode 100644 lua/toolchain/config/plugins.lua create mode 100644 lua/toolchain/config/requirements.lua create mode 100644 lua/toolchain/database/actions.lua create mode 100644 lua/toolchain/database/debugger.lua create mode 100644 lua/toolchain/database/diagnostics.lua create mode 100644 lua/toolchain/database/formatter.lua create mode 100644 lua/toolchain/database/init.lua create mode 100644 lua/toolchain/database/language_server.lua create mode 100644 lua/toolchain/database/plugins.lua create mode 100644 lua/toolchain/database/requirements.lua create mode 100644 lua/toolchain/frontend/actions.lua create mode 100644 lua/toolchain/frontend/debugger.lua create mode 100644 lua/toolchain/frontend/diagnostics.lua create mode 100644 lua/toolchain/frontend/formatter.lua create mode 100644 lua/toolchain/frontend/init.lua create mode 100644 lua/toolchain/frontend/language_server.lua create mode 100644 lua/toolchain/frontend/plugins.lua create mode 100644 lua/toolchain/frontend/requirements.lua create mode 100644 lua/toolchain/generic/actions.lua create mode 100644 lua/toolchain/generic/debugger.lua create mode 100644 lua/toolchain/generic/diagnostics.lua create mode 100644 lua/toolchain/generic/formatter.lua create mode 100644 lua/toolchain/generic/init.lua create mode 100644 lua/toolchain/generic/language_server.lua create mode 100644 lua/toolchain/generic/plugins.lua create mode 100644 lua/toolchain/generic/requirements.lua create mode 100644 lua/toolchain/git/actions.lua create mode 100644 lua/toolchain/git/debugger.lua create mode 100644 lua/toolchain/git/diagnostics.lua create mode 100644 lua/toolchain/git/formatter.lua create mode 100644 lua/toolchain/git/init.lua create mode 100644 lua/toolchain/git/language_server.lua create mode 100644 lua/toolchain/git/plugins.lua create mode 100644 lua/toolchain/git/requirements.lua create mode 100644 lua/toolchain/go/actions.lua create mode 100644 lua/toolchain/go/debugger.lua create mode 100644 lua/toolchain/go/diagnostics.lua create mode 100644 lua/toolchain/go/formatter.lua create mode 100644 lua/toolchain/go/init.lua create mode 100644 lua/toolchain/go/language_server.lua create mode 100644 lua/toolchain/go/plugins.lua create mode 100644 lua/toolchain/go/requirements.lua create mode 100644 lua/toolchain/lua/actions.lua create mode 100644 lua/toolchain/lua/debugger.lua create mode 100644 lua/toolchain/lua/diagnostics.lua create mode 100644 lua/toolchain/lua/formatter.lua create mode 100644 lua/toolchain/lua/init.lua create mode 100644 lua/toolchain/lua/language_server.lua create mode 100644 lua/toolchain/lua/plugins.lua create mode 100644 lua/toolchain/lua/requirements.lua create mode 100644 lua/toolchain/php/actions.lua create mode 100644 lua/toolchain/php/debugger.lua create mode 100644 lua/toolchain/php/diagnostics.lua create mode 100644 lua/toolchain/php/formatter.lua create mode 100644 lua/toolchain/php/init.lua create mode 100644 lua/toolchain/php/language_server.lua create mode 100644 lua/toolchain/php/plugins.lua create mode 100644 lua/toolchain/php/requirements.lua create mode 100644 lua/toolchain/scripts/actions.lua create mode 100644 lua/toolchain/scripts/debugger.lua create mode 100644 lua/toolchain/scripts/diagnostics.lua create mode 100644 lua/toolchain/scripts/formatter.lua create mode 100644 lua/toolchain/scripts/init.lua create mode 100644 lua/toolchain/scripts/language_server.lua create mode 100644 lua/toolchain/scripts/plugins.lua create mode 100644 lua/toolchain/scripts/requirements.lua create mode 100644 lua/toolchain/text/actions.lua create mode 100644 lua/toolchain/text/debugger.lua create mode 100644 lua/toolchain/text/diagnostics.lua create mode 100644 lua/toolchain/text/formatter.lua create mode 100644 lua/toolchain/text/init.lua create mode 100644 lua/toolchain/text/language_server.lua create mode 100644 lua/toolchain/text/plugins.lua create mode 100644 lua/toolchain/text/requirements.lua create mode 100644 lua/toolchain/web/actions.lua create mode 100644 lua/toolchain/web/debugger.lua create mode 100644 lua/toolchain/web/diagnostics.lua create mode 100644 lua/toolchain/web/formatter.lua create mode 100644 lua/toolchain/web/init.lua create mode 100644 lua/toolchain/web/language_server.lua create mode 100644 lua/toolchain/web/plugins.lua create mode 100644 lua/toolchain/web/requirements.lua create mode 100644 lua/util/finder.lua create mode 100644 lua/util/toolchain.lua create mode 100644 stylua.toml diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..f9c1b6c --- /dev/null +++ b/Readme.md @@ -0,0 +1,36 @@ +# Dotfiles/nvim + +## Install dependencies + +### Fedora + +#### Enable Coprs +```sh +dnf copr enable yorickpeterse/stylua -y +``` + +#### Add YUM Repos +```sh +echo '[charm] +name=Charm +baseurl=https://repo.charm.sh/yum/ +enabled=1 +gpgcheck=1 +gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo +``` + +#### Install System Packages +```sh +dnf install -y neovim lua gcc curl wget git unzip tar gzip ripgrep php composer go nodejs npm delve stylua codespell cargo +``` + +#### Install Cargo packages +```sh +cargo install selene +``` + +#### Install NPM packages +```sh +npm install -g @fsouza/prettierd +npm install -g eslint_d +``` diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5700b24 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require('core') diff --git a/lua/core/editor.lua b/lua/core/editor.lua new file mode 100644 index 0000000..5a56369 --- /dev/null +++ b/lua/core/editor.lua @@ -0,0 +1,8 @@ +-- Use 2 Spaces Instead of Tabs -- +vim.opt.expandtab = true +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 + +-- Enable Line Number -- +vim.opt.number = true diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..6798319 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,3 @@ +require('core.keymap') +require('core.editor') +require('core.package_manager') diff --git a/lua/core/keymap.lua b/lua/core/keymap.lua new file mode 100644 index 0000000..652ca1e --- /dev/null +++ b/lua/core/keymap.lua @@ -0,0 +1,5 @@ +vim.g.mapleader = ' ' + +--[[ Indentation ]] +vim.keymap.set('n', '', '>>') +vim.keymap.set('n', '', '<<') diff --git a/lua/core/package_manager.lua b/lua/core/package_manager.lua new file mode 100644 index 0000000..7fdf307 --- /dev/null +++ b/lua/core/package_manager.lua @@ -0,0 +1,19 @@ +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +local plugins = require('util.toolchain').plugins +table.insert(plugins, 1, { import = 'editor' }) + +require('lazy').setup({ + spec = plugins, +}) diff --git a/lua/editor/auto_brackets.lua b/lua/editor/auto_brackets.lua new file mode 100644 index 0000000..2799654 --- /dev/null +++ b/lua/editor/auto_brackets.lua @@ -0,0 +1,4 @@ +return { + 'm4xshen/autoclose.nvim', + config = function() require('autoclose').setup() end, +} diff --git a/lua/editor/dashboard.lua b/lua/editor/dashboard.lua new file mode 100644 index 0000000..215160a --- /dev/null +++ b/lua/editor/dashboard.lua @@ -0,0 +1,32 @@ +return { + 'goolord/alpha-nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = function() + -- Setup -- + local alpha = require('alpha') + local dashboard = require('alpha.themes.startify') + + -- Header -- + dashboard.section.header.val = { + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[  ]], + [[ ████ ██████ █████ ██ ]], + [[ ███████████ █████  ]], + [[ █████████ ███████████████████ ███ ███████████ ]], + [[ █████████ ███ █████████████ █████ ██████████████ ]], + [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], + [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], + [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], + [[ ]], + [[ ]], + [[ ]], + } + + alpha.setup(dashboard.opts) + end, +} diff --git a/lua/editor/debugging.lua b/lua/editor/debugging.lua new file mode 100644 index 0000000..bf66d70 --- /dev/null +++ b/lua/editor/debugging.lua @@ -0,0 +1,115 @@ +return { + 'mfussenegger/nvim-dap', + dependencies = { + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', + }, + config = function() + -- Setup Debugging -- + local dap = require('dap') + + -- Open UI on Debugging -- + local dapui = require('dapui') + dapui.setup({ + layouts = { + { + elements = { + { id = 'scopes', size = 0.65 }, + { id = 'breakpoints', size = 0.35 }, + }, + position = 'left', + size = 40, + }, + { + elements = { + { id = 'repl', size = 0.5 }, + { id = 'console', size = 0.5 }, + }, + position = 'bottom', + size = 10, + }, + }, + }) + dap.listeners.before.attach.dapui_config = function() dapui.open() end + dap.listeners.before.launch.dapui_config = function() dapui.open() end + + -- Keybinding -- + vim.keymap.set( + 'n', + 'dt', + dapui.toggle, + { desc = 'Toggle Debugger UI' } + ) + vim.keymap.set( + 'n', + 'db', + dap.toggle_breakpoint, + { desc = 'Toggle Breakpoint' } + ) + vim.keymap.set( + 'n', + 'dc', + dap.continue, + { desc = 'Debugger Continue' } + ) + vim.keymap.set( + 'n', + 'dx', + dap.terminate, + { desc = 'Debugger Terminate' } + ) + vim.keymap.set( + 'n', + 'ds', + dap.step_over, + { desc = 'Debugger Step Over' } + ) + + -- Breakpoints -- + vim.api.nvim_set_hl( + 0, + 'DapBreakpoint', + { ctermbg = 0, fg = '#993939', bg = '#31353f' } + ) + vim.api.nvim_set_hl( + 0, + 'DapLogPoint', + { ctermbg = 0, fg = '#61afef', bg = '#31353f' } + ) + vim.api.nvim_set_hl( + 0, + 'DapStopped', + { ctermbg = 0, fg = '#98c379', bg = '#31353f' } + ) + vim.fn.sign_define('DapBreakpoint', { + text = '', + texthl = 'DapBreakpoint', + linehl = 'DapBreakpoint', + numhl = 'DapBreakpoint', + }) + vim.fn.sign_define('DapBreakpointCondition', { + text = '󰣏', + texthl = 'DapBreakpoint', + linehl = 'DapBreakpoint', + numhl = 'DapBreakpoint', + }) + vim.fn.sign_define('DapBreakpointRejected', { + text = '', + texthl = 'DapBreakpoint', + linehl = 'DapBreakpoint', + numhl = 'DapBreakpoint', + }) + vim.fn.sign_define('DapLogPoint', { + text = '', + texthl = 'DapLogPoint', + linehl = 'DapLogPoint', + numhl = 'DapLogPoint', + }) + vim.fn.sign_define('DapStopped', { + text = '', + texthl = 'DapStopped', + linehl = 'DapStopped', + numhl = 'DapStopped', + }) + end, +} diff --git a/lua/editor/file_tree.lua b/lua/editor/file_tree.lua new file mode 100644 index 0000000..25299ab --- /dev/null +++ b/lua/editor/file_tree.lua @@ -0,0 +1,81 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + }, + config = function() + -- Setup -- + require('neo-tree').setup({ + close_if_last_window = false, + enable_git_status = true, + enable_diagnostics = true, + name = { + trailing_slash = false, + use_git_status_colors = true, + highlight = 'NeoTreeFileName', + }, + git_status = { + symbols = { + -- Git Change type Icon -- + added = '✚', + modified = '', + deleted = '✖', + renamed = '󰁕', + -- Git Status type Icon -- + untracked = '', + ignored = '', + unstaged = '󰄱', + staged = '', + conflict = '', + }, + }, + symlink_target = { + enabled = false, + }, + filesystem = { + hijack_netrw_behavior = 'open_default', + }, + -- Keybinding -- + window = { + mappings = { + [''] = 'open', + }, + }, + }) + + -- Dignostic Icons -- + vim.fn.sign_define('DiagnosticSignError', { + text = ' ', + texthl = 'DiagnosticSignError', + }) + vim.fn.sign_define('DiagnosticSignWarn', { + text = ' ', + texthl = 'DiagnosticSignWarn', + }) + vim.fn.sign_define('DiagnosticSignInfo', { + text = ' ', + texthl = 'DiagnosticSignInfo', + }) + vim.fn.sign_define('DiagnosticSignHint', { + text = '󰌵', + texthl = 'DiagnosticSignHint', + }) + + -- Keybinding -- + vim.keymap.set( + 'n', + 'ft', + ':Neotree toggle reveal left', + { desc = 'Toggle File Tree' } + ) + vim.keymap.set( + 'n', + 'fo', + ':Neotree buffers reveal float', + { desc = 'Show Open Files' } + ) + end, +} diff --git a/lua/editor/highlighting.lua b/lua/editor/highlighting.lua new file mode 100644 index 0000000..65cf63e --- /dev/null +++ b/lua/editor/highlighting.lua @@ -0,0 +1,14 @@ +return { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + -- Setup -- + local config = require('nvim-treesitter.configs') + config.setup({ + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = require('util.toolchain').highlighters, + }) + end, +} diff --git a/lua/editor/key_list.lua b/lua/editor/key_list.lua new file mode 100644 index 0000000..93aefa2 --- /dev/null +++ b/lua/editor/key_list.lua @@ -0,0 +1,8 @@ +return { + 'folke/which-key.nvim', + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + require('which-key').setup({}) + end, +} diff --git a/lua/editor/language_server.lua b/lua/editor/language_server.lua new file mode 100644 index 0000000..3835f2f --- /dev/null +++ b/lua/editor/language_server.lua @@ -0,0 +1,118 @@ +local TOOLCHAIN = require('util.toolchain') + +return { + { + 'williamboman/mason.nvim', + lazy = false, + config = function() require('mason').setup() end, + }, + { + 'williamboman/mason-lspconfig.nvim', + lazy = false, + opts = { + auto_install = true, + }, + config = function() + require('mason-lspconfig').setup({ + ensure_installed = TOOLCHAIN.lsp_requriemts, + }) + end, + }, + { + 'neovim/nvim-lspconfig', + lazy = false, + config = function() + -- Setup -- + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local lspconfig = require('lspconfig') + + for _, setup in ipairs(TOOLCHAIN.lsp_setups) do + setup(lspconfig, capabilities) + end + + -- Keybinding -- + vim.keymap.set( + 'n', + 'cd', + vim.lsp.buf.hover, + { desc = 'Show Code Definition' } + ) + vim.keymap.set( + 'n', + 'gd', + vim.lsp.buf.definition, + { desc = 'Go to Definition' } + ) + vim.keymap.set( + 'n', + 'gr', + vim.lsp.buf.references, + { desc = 'Go to References' } + ) + vim.keymap.set( + 'n', + 'ca', + vim.lsp.buf.code_action, + { desc = 'Do Code Actions' } + ) + end, + }, + { + 'nvimtools/none-ls.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvimtools/none-ls-extras.nvim', + }, + config = function() + -- Setup -- + local null_ls = require('null-ls') + + local null_ls_sources = {} + for _, setup_function in ipairs(TOOLCHAIN.null_ls) do + local conf = setup_function(null_ls) + if #conf ~= 0 then + for _, _conf in pairs(conf) do + table.insert(null_ls_sources, _conf) + end + end + end + + null_ls.setup({ + sources = null_ls_sources, + }) + + -- Keybinding -- + vim.keymap.set( + 'n', + 'fc', + vim.lsp.buf.format, + { desc = 'Format Code' } + ) + end, + }, + { + 'nvimdev/lspsaga.nvim', + after = 'nvim-lspconfig', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'nvim-tree/nvim-web-devicons', + }, + config = function() + require('lspsaga').setup({}) + + -- Keybinding -- + vim.keymap.set( + 'n', + 'cr', + ':Lspsaga rename', + { desc = 'Rename Variable' } + ) + vim.keymap.set( + 'n', + 'cp', + ':Lspsaga peek_definition', + { desc = 'Peek Code Definition' } + ) + end, + }, +} diff --git a/lua/editor/llm.lua b/lua/editor/llm.lua new file mode 100644 index 0000000..ed2f6ed --- /dev/null +++ b/lua/editor/llm.lua @@ -0,0 +1,57 @@ +local explain_prompt = [[ +Explain this Code short and Precise: +$fname +```$ftype +$buf +``` +--- +]] + +local generate_prompt = [[ +<|fim_prefix|>$before<|fim_suffix|>$after<|fim_middle|> +]] + +return { + dir = '~/Workspace/nvim/ollama.nvim', + --"nomnivore/ollama.nvim", + config = function() + local ollama = require('ollama') + ollama.setup({ + model = 'codegemma:instruct', + prompts = { + Ask_About_Code = false, + Modify_Code = false, + Raw = false, + Simplify_Code = false, + Explain_Code = { + model = 'codegemma:instruct', + prompt = explain_prompt, + input_label = '>', + action = require('ollama.actions.factory').create_action({ + display = true, + window = 'vsplit', + }), + }, + Generate_Code = { + model = 'codegemma:2b-code', + prompt = generate_prompt, + input_label = '>', + action = 'display', + options = { + num_predict = 128, + temperature = 0.0, + top_p = 0.9, + stop = { '<|file_separator|>' }, + }, + }, + }, + }) + + vim.keymap.set( + 'n', + 'op', + ollama.prompt, + { desc = 'Ollama Prompt' } + ) + end, +} diff --git a/lua/editor/search.lua b/lua/editor/search.lua new file mode 100644 index 0000000..64cb3bb --- /dev/null +++ b/lua/editor/search.lua @@ -0,0 +1,68 @@ +return { + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-ui-select.nvim', + }, + config = function() + -- Setup -- + require('telescope').setup({ + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown({}), + }, + }, + }) + require('telescope').load_extension('ui-select') + + -- Keybinding -- + local function setTelescopeBinding( + mode, + keymap, + method, + search_global, + description + ) + local function binding() + local path = search_global and '~' + or require('neo-tree.sources.manager').get_state( + 'filesystem' + ).path + method({ search_dirs = { path } }) + end + vim.keymap.set(mode, keymap, binding, { desc = description }) + end + + local telescope = require('telescope.builtin') + + setTelescopeBinding( + 'n', + 'ff', + telescope.find_files, + false, + 'Find File' + ) + setTelescopeBinding( + 'n', + 'fz', + telescope.live_grep, + false, + 'Fuzzy Find' + ) + setTelescopeBinding( + 'n', + 'gff', + telescope.find_files, + true, + 'Global Find File' + ) + setTelescopeBinding( + 'n', + 'gfz', + telescope.live_grep, + true, + 'Global Fuzzy Find' + ) + end, +} diff --git a/lua/editor/snippets.lua b/lua/editor/snippets.lua new file mode 100644 index 0000000..00b6589 --- /dev/null +++ b/lua/editor/snippets.lua @@ -0,0 +1,76 @@ +return { + { + 'L3MON4D3/LuaSnip', + version = '2.*', + dependencies = { + 'rafamadriz/friendly-snippets', + 'mireq/luasnip-snippets', + }, + build = 'make install_jsregexp', + config = function() + -- Setup -- + require('luasnip.loaders.from_vscode').lazy_load() + require('luasnip.loaders.from_snipmate').lazy_load() + require('luasnip_snippets.common.snip_utils').setup() + end, + }, + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lsp', + }, + config = function() + -- Setup -- + local cmp = require('cmp') + local luasnip = require('luasnip') + luasnip.setup({ + load_ft_func = require('luasnip_snippets.common.snip_utils').load_ft_func, + ft_func = require('luasnip_snippets.common.snip_utils').ft_func, + enable_autosnippets = true, + }) + + -- Keybinding -- + vim.keymap.set({ 'i', 's' }, '', function() + if luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + vim.api.nvim_input('') + end + end, { silent = true }) + + vim.keymap.set( + { 'i', 's' }, + '', + function() luasnip.jump(-1) end, + { silent = true } + ) + + local doc_keybindings = { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + } + + -- Setup -- + cmp.setup({ + snippet = { + expand = function(args) luasnip.lsp_expand(args.body) end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert(doc_keybindings), + sources = cmp.config.sources({ + { name = 'lazydev', group_index = 0 }, + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { { name = 'buffer' } }), + }) + end, + }, +} diff --git a/lua/editor/status_bar.lua b/lua/editor/status_bar.lua new file mode 100644 index 0000000..2724ae6 --- /dev/null +++ b/lua/editor/status_bar.lua @@ -0,0 +1,77 @@ +return { + { + 'nvim-lualine/lualine.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + 'nvimdev/lspsaga.nvim', + }, + after = 'rcarriga/nvim-dap-ui', + config = function() + -- Setup -- + local lspsaga_breadcrumbs = require('lspsaga.symbol.winbar').get_bar + + require('lualine').setup({ + options = { + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + disabled_filetypes = { + 'neo-tree', + 'fugitive', + 'help', + statusline = { + 'dap-repl', + 'dapui_console', + 'dapui_console', + 'dapui_watches', + 'dapui_stacks', + 'dapui_breakpoints', + 'dapui_scopes', + }, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'diagnostics' }, + lualine_c = { lspsaga_breadcrumbs }, + lualine_x = { 'location' }, + lualine_y = { 'diff', 'branch' }, + lualine_z = { 'filetype' }, + }, + inactive_sections = { + lualine_a = { 'mode' }, + lualine_b = { 'diagnostics' }, + lualine_c = {}, + lualine_x = { 'location' }, + lualine_y = { 'diff', 'branch' }, + lualine_z = { 'filetype' }, + }, + tabline = {}, + winbar = { + lualine_a = { 'filename' }, + }, + inactive_winbar = { + lualine_a = { 'filename' }, + }, + extensions = { + require('temp.status_bar_plugin'), + }, + }) + end, + }, + { + 'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', + 'nvim-tree/nvim-web-devicons', + }, + config = function() require('barbar').setup() end, + }, +} diff --git a/lua/editor/terminal.lua b/lua/editor/terminal.lua new file mode 100644 index 0000000..398b680 --- /dev/null +++ b/lua/editor/terminal.lua @@ -0,0 +1,30 @@ +return { + 'rebelot/terminal.nvim', + config = function() + local terminal = require('terminal') + terminal.setup({ + layout = { + open_cmd = 'vertical new', + }, + cmd = { 'bash' }, + autoclose = true, + }) + + local project_dir = require('util.finder').get_opened_folder() + local term + local function toggle() + if term == nil then + term = terminal.terminal:new() + term.cwd = project_dir + end + term:toggle() + end + + vim.keymap.set( + { 'n', 't' }, + '', + toggle, + { desc = 'Toggle Terminal' } + ) + end, +} diff --git a/lua/editor/theme.lua b/lua/editor/theme.lua new file mode 100644 index 0000000..ecc4d4f --- /dev/null +++ b/lua/editor/theme.lua @@ -0,0 +1,9 @@ +return { + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1000, + config = function() + -- Set Theme -- + vim.cmd('colorscheme catppuccin') + end, +} diff --git a/lua/temp/status_bar_plugin.lua b/lua/temp/status_bar_plugin.lua new file mode 100644 index 0000000..dc12205 --- /dev/null +++ b/lua/temp/status_bar_plugin.lua @@ -0,0 +1,65 @@ +local M = {} + +M.filetypes = { + 'dap-repl', + 'dapui_console', + 'dapui_console', + 'dapui_watches', + 'dapui_stacks', + 'dapui_breakpoints', + 'dapui_scopes', +} + +local function merge_colors(foreground, background) + local new_name = foreground .. background + + local hl_fg = vim.api.nvim_get_hl(0, { name = foreground }) + local hl_bg = vim.api.nvim_get_hl(0, { name = background }) + + local fg = string.format('#%06x', hl_fg.fg and hl_fg.fg or 0) + local bg = string.format('#%06x', hl_bg.bg and hl_bg.bg or 0) + + vim.api.nvim_set_hl(0, new_name, { fg = fg, bg = bg }) + return new_name +end + +local function get_dap_repl_winbar(active) + local get_mode = require('lualine.highlight').get_mode_suffix + + return function() + local filetype = vim.bo.filetype + local disabled_filetypes = { 'dap-repl' } + + if not vim.tbl_contains(disabled_filetypes, filetype) then + return '' + end + + local background_color = string.format( + 'lualine_b' .. '%s', + active and get_mode() or '_inactive' + ) + + local controls_string = '%#' .. background_color .. '#' + for element in require('dapui.controls').controls():gmatch('%S+') do + local color, action = string.match(element, '%%#(.*)#(%%.*)%%#0#') + controls_string = controls_string + .. ' %#' + .. merge_colors(color, background_color) + .. '#' + .. action + end + return controls_string + end +end + +M.winbar = { + lualine_a = { { 'filename', file_status = false } }, + lualine_b = { get_dap_repl_winbar(true) }, +} + +M.inactive_winbar = { + lualine_a = { { 'filename', file_status = false } }, + lualine_b = { get_dap_repl_winbar(false) }, +} + +return M diff --git a/lua/toolchain/config/actions.lua b/lua/toolchain/config/actions.lua new file mode 100644 index 0000000..b6fa425 --- /dev/null +++ b/lua/toolchain/config/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/config/debugger.lua b/lua/toolchain/config/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/config/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/config/diagnostics.lua b/lua/toolchain/config/diagnostics.lua new file mode 100644 index 0000000..28d9c74 --- /dev/null +++ b/lua/toolchain/config/diagnostics.lua @@ -0,0 +1,10 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.spectral, + --null_ls.builtins.diagnostics.vacuum --Pure Openapi linter + } + end, +} diff --git a/lua/toolchain/config/formatter.lua b/lua/toolchain/config/formatter.lua new file mode 100644 index 0000000..f7ecfd2 --- /dev/null +++ b/lua/toolchain/config/formatter.lua @@ -0,0 +1,5 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/config/init.lua b/lua/toolchain/config/init.lua new file mode 100644 index 0000000..dbd366c --- /dev/null +++ b/lua/toolchain/config/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.config.requirements'), + language_servers = require('toolchain.config.language_server'), + formatters = require('toolchain.config.formatter'), + actions = require('toolchain.config.actions'), + diagnostics = require('toolchain.config.diagnostics'), + debuggers = require('toolchain.config.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/config/language_server.lua b/lua/toolchain/config/language_server.lua new file mode 100644 index 0000000..18b6998 --- /dev/null +++ b/lua/toolchain/config/language_server.lua @@ -0,0 +1,16 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'jsonls', + 'lemminx', + 'yamlls', + 'taplo', + }, + setup = function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.jsonls.setup(config) + lspconfig.lemminx.setup(config) + lspconfig.yamlls.setup(config) + lspconfig.taplo.setup(config) + end, +} diff --git a/lua/toolchain/config/plugins.lua b/lua/toolchain/config/plugins.lua new file mode 100644 index 0000000..8754578 --- /dev/null +++ b/lua/toolchain/config/plugins.lua @@ -0,0 +1,9 @@ +return { + { + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = {}, + }, + }, +} diff --git a/lua/toolchain/config/requirements.lua b/lua/toolchain/config/requirements.lua new file mode 100644 index 0000000..0e7bf96 --- /dev/null +++ b/lua/toolchain/config/requirements.lua @@ -0,0 +1,17 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.config.formatter').plugins), + table.unpack(require('toolchain.config.actions').plugins), + table.unpack(require('toolchain.config.diagnostics').plugins), + table.unpack(require('toolchain.config.debugger').plugins), + table.unpack(require('toolchain.config.plugins')), + }, + highlighters = { + 'json', + 'xml', + 'yaml', + 'toml', + }, + language_servers = require('toolchain.config.language_server').requirements, +} diff --git a/lua/toolchain/database/actions.lua b/lua/toolchain/database/actions.lua new file mode 100644 index 0000000..b6fa425 --- /dev/null +++ b/lua/toolchain/database/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/database/debugger.lua b/lua/toolchain/database/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/database/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/database/diagnostics.lua b/lua/toolchain/database/diagnostics.lua new file mode 100644 index 0000000..d9057cd --- /dev/null +++ b/lua/toolchain/database/diagnostics.lua @@ -0,0 +1,5 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/database/formatter.lua b/lua/toolchain/database/formatter.lua new file mode 100644 index 0000000..f7ecfd2 --- /dev/null +++ b/lua/toolchain/database/formatter.lua @@ -0,0 +1,5 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/database/init.lua b/lua/toolchain/database/init.lua new file mode 100644 index 0000000..5247db4 --- /dev/null +++ b/lua/toolchain/database/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.database.requirements'), + language_servers = require('toolchain.database.language_server'), + formatters = require('toolchain.database.formatter'), + actions = require('toolchain.database.actions'), + diagnostics = require('toolchain.database.diagnostics'), + debuggers = require('toolchain.database.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/database/language_server.lua b/lua/toolchain/database/language_server.lua new file mode 100644 index 0000000..5a5c598 --- /dev/null +++ b/lua/toolchain/database/language_server.lua @@ -0,0 +1,10 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'sqlls', + }, + setup = function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.sqlls.setup(config) + end, +} diff --git a/lua/toolchain/database/plugins.lua b/lua/toolchain/database/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/database/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/database/requirements.lua b/lua/toolchain/database/requirements.lua new file mode 100644 index 0000000..2c249e5 --- /dev/null +++ b/lua/toolchain/database/requirements.lua @@ -0,0 +1,14 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.database.formatter').plugins), + table.unpack(require('toolchain.database.actions').plugins), + table.unpack(require('toolchain.database.diagnostics').plugins), + table.unpack(require('toolchain.database.debugger').plugins), + table.unpack(require('toolchain.database.plugins')), + }, + highlighters = { + 'sql', + }, + language_servers = require('toolchain.database.language_server').requirements, +} diff --git a/lua/toolchain/frontend/actions.lua b/lua/toolchain/frontend/actions.lua new file mode 100644 index 0000000..b6fa425 --- /dev/null +++ b/lua/toolchain/frontend/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/frontend/debugger.lua b/lua/toolchain/frontend/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/frontend/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/frontend/diagnostics.lua b/lua/toolchain/frontend/diagnostics.lua new file mode 100644 index 0000000..d9057cd --- /dev/null +++ b/lua/toolchain/frontend/diagnostics.lua @@ -0,0 +1,5 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/frontend/formatter.lua b/lua/toolchain/frontend/formatter.lua new file mode 100644 index 0000000..f7ecfd2 --- /dev/null +++ b/lua/toolchain/frontend/formatter.lua @@ -0,0 +1,5 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/frontend/init.lua b/lua/toolchain/frontend/init.lua new file mode 100644 index 0000000..1bf50f3 --- /dev/null +++ b/lua/toolchain/frontend/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.frontend.requirements'), + language_servers = require('toolchain.frontend.language_server'), + formatters = require('toolchain.frontend.formatter'), + actions = require('toolchain.frontend.actions'), + diagnostics = require('toolchain.frontend.diagnostics'), + debuggers = require('toolchain.frontend.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/frontend/language_server.lua b/lua/toolchain/frontend/language_server.lua new file mode 100644 index 0000000..62204c9 --- /dev/null +++ b/lua/toolchain/frontend/language_server.lua @@ -0,0 +1,12 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'svelte', + 'volar', + }, + setup = function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.svelte.setup(config) + lspconfig.volar.setup(config) + end, +} diff --git a/lua/toolchain/frontend/plugins.lua b/lua/toolchain/frontend/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/frontend/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/frontend/requirements.lua b/lua/toolchain/frontend/requirements.lua new file mode 100644 index 0000000..7c492ef --- /dev/null +++ b/lua/toolchain/frontend/requirements.lua @@ -0,0 +1,16 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.frontend.formatter').plugins), + table.unpack(require('toolchain.frontend.actions').plugins), + table.unpack(require('toolchain.frontend.diagnostics').plugins), + table.unpack(require('toolchain.frontend.debugger').plugins), + table.unpack(require('toolchain.frontend.plugins')), + }, + + highlighters = { + 'svelte', + 'vue', + }, + language_servers = require('toolchain.frontend.language_server').requirements, +} diff --git a/lua/toolchain/generic/actions.lua b/lua/toolchain/generic/actions.lua new file mode 100644 index 0000000..217a9f7 --- /dev/null +++ b/lua/toolchain/generic/actions.lua @@ -0,0 +1,9 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.code_actions.refactoring, + } + end, +} diff --git a/lua/toolchain/generic/debugger.lua b/lua/toolchain/generic/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/generic/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/generic/diagnostics.lua b/lua/toolchain/generic/diagnostics.lua new file mode 100644 index 0000000..d9057cd --- /dev/null +++ b/lua/toolchain/generic/diagnostics.lua @@ -0,0 +1,5 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/generic/formatter.lua b/lua/toolchain/generic/formatter.lua new file mode 100644 index 0000000..f7ecfd2 --- /dev/null +++ b/lua/toolchain/generic/formatter.lua @@ -0,0 +1,5 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/generic/init.lua b/lua/toolchain/generic/init.lua new file mode 100644 index 0000000..809f47b --- /dev/null +++ b/lua/toolchain/generic/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.generic.requirements'), + language_servers = require('toolchain.generic.language_server'), + formatters = require('toolchain.generic.formatter'), + actions = require('toolchain.generic.actions'), + diagnostics = require('toolchain.generic.diagnostics'), + debuggers = require('toolchain.generic.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/generic/language_server.lua b/lua/toolchain/generic/language_server.lua new file mode 100644 index 0000000..d52007d --- /dev/null +++ b/lua/toolchain/generic/language_server.lua @@ -0,0 +1,5 @@ +---@type ToolchainLanguageServers +return { + requirements = {}, + setup = function(_lspgeneric, _capabilities) end, +} diff --git a/lua/toolchain/generic/plugins.lua b/lua/toolchain/generic/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/generic/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/generic/requirements.lua b/lua/toolchain/generic/requirements.lua new file mode 100644 index 0000000..733f094 --- /dev/null +++ b/lua/toolchain/generic/requirements.lua @@ -0,0 +1,12 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.generic.formatter').plugins), + table.unpack(require('toolchain.generic.actions').plugins), + table.unpack(require('toolchain.generic.diagnostics').plugins), + table.unpack(require('toolchain.generic.debugger').plugins), + table.unpack(require('toolchain.generic.plugins')), + }, + highlighters = {}, + language_servers = require('toolchain.generic.language_server').requirements, +} diff --git a/lua/toolchain/git/actions.lua b/lua/toolchain/git/actions.lua new file mode 100644 index 0000000..b6fa425 --- /dev/null +++ b/lua/toolchain/git/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/git/debugger.lua b/lua/toolchain/git/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/git/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/git/diagnostics.lua b/lua/toolchain/git/diagnostics.lua new file mode 100644 index 0000000..d9057cd --- /dev/null +++ b/lua/toolchain/git/diagnostics.lua @@ -0,0 +1,5 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/git/formatter.lua b/lua/toolchain/git/formatter.lua new file mode 100644 index 0000000..f7ecfd2 --- /dev/null +++ b/lua/toolchain/git/formatter.lua @@ -0,0 +1,5 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/git/init.lua b/lua/toolchain/git/init.lua new file mode 100644 index 0000000..9e3f042 --- /dev/null +++ b/lua/toolchain/git/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.git.requirements'), + language_servers = require('toolchain.git.language_server'), + formatters = require('toolchain.git.formatter'), + actions = require('toolchain.git.actions'), + diagnostics = require('toolchain.git.diagnostics'), + debuggers = require('toolchain.git.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/git/language_server.lua b/lua/toolchain/git/language_server.lua new file mode 100644 index 0000000..1d8b636 --- /dev/null +++ b/lua/toolchain/git/language_server.lua @@ -0,0 +1,5 @@ +---@type ToolchainLanguageServers +return { + requirements = {}, + setup = function(_lspconfig, _capabilities) end, +} diff --git a/lua/toolchain/git/plugins.lua b/lua/toolchain/git/plugins.lua new file mode 100644 index 0000000..09f0f02 --- /dev/null +++ b/lua/toolchain/git/plugins.lua @@ -0,0 +1,38 @@ +return { + { + 'tpope/vim-fugitive', + }, + { + 'lewis6991/gitsigns.nvim', + config = function() + -- Setup -- + require('gitsigns').setup() + + -- Keybinding -- + vim.keymap.set( + 'n', + 'gh', + ':Gitsigns preview_hunk_inline', + { desc = 'Toggle Inline Git Diff' } + ) + vim.keymap.set( + 'n', + 'gb', + ':Gitsigns toggle_current_line_blame', + { desc = 'Toggle Inline Git Blame' } + ) + vim.keymap.set( + 'n', + 'go', + ':Git ', + { desc = 'Open Git' } + ) + end, + }, + { + 'moyiz/git-dev.nvim', + lazy = true, + cmd = { 'GitDevOpen', 'GitDevCleanAll' }, + opts = {}, + }, +} diff --git a/lua/toolchain/git/requirements.lua b/lua/toolchain/git/requirements.lua new file mode 100644 index 0000000..11a1d39 --- /dev/null +++ b/lua/toolchain/git/requirements.lua @@ -0,0 +1,18 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.git.formatter').plugins), + table.unpack(require('toolchain.git.actions').plugins), + table.unpack(require('toolchain.git.diagnostics').plugins), + table.unpack(require('toolchain.git.debugger').plugins), + table.unpack(require('toolchain.git.plugins')), + }, + highlighters = { + 'gitcommit', + 'gitignore', + 'gitattributes', + 'git_rebase', + 'git_config', + }, + language_servers = require('toolchain.git.language_server').requirements, +} diff --git a/lua/toolchain/go/actions.lua b/lua/toolchain/go/actions.lua new file mode 100644 index 0000000..354c4ae --- /dev/null +++ b/lua/toolchain/go/actions.lua @@ -0,0 +1,10 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.code_actions.gomodifytags, + null_ls.builtins.code_actions.impl, + } + end, +} diff --git a/lua/toolchain/go/debugger.lua b/lua/toolchain/go/debugger.lua new file mode 100644 index 0000000..150fa6c --- /dev/null +++ b/lua/toolchain/go/debugger.lua @@ -0,0 +1,18 @@ +---@type ToolchainDebuggers +return { + plugins = { + { + 'leoluz/nvim-dap-go', + config = function() + local dir = require('util.finder').find_project_dir( + 'go.mod', + 3, + { 'src', 'app', 'pkg' }, + { 'test' }, + true + ) + require('dap-go').setup({ delve = { cwd = dir } }) + end, + }, + }, +} diff --git a/lua/toolchain/go/diagnostics.lua b/lua/toolchain/go/diagnostics.lua new file mode 100644 index 0000000..230936f --- /dev/null +++ b/lua/toolchain/go/diagnostics.lua @@ -0,0 +1,10 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.golangci_lint, + null_ls.builtins.diagnostics.staticcheck, + } + end, +} diff --git a/lua/toolchain/go/formatter.lua b/lua/toolchain/go/formatter.lua new file mode 100644 index 0000000..5a33f19 --- /dev/null +++ b/lua/toolchain/go/formatter.lua @@ -0,0 +1,9 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.formatting.gofumpt, + } + end, +} diff --git a/lua/toolchain/go/init.lua b/lua/toolchain/go/init.lua new file mode 100644 index 0000000..0596f4a --- /dev/null +++ b/lua/toolchain/go/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.go.requirements'), + language_servers = require('toolchain.go.language_server'), + formatters = require('toolchain.go.formatter'), + actions = require('toolchain.go.actions'), + diagnostics = require('toolchain.go.diagnostics'), + debuggers = require('toolchain.go.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/go/language_server.lua b/lua/toolchain/go/language_server.lua new file mode 100644 index 0000000..408f5d5 --- /dev/null +++ b/lua/toolchain/go/language_server.lua @@ -0,0 +1,9 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'gopls', + }, + setup = function(lspconfig, capabilities) + lspconfig.gopls.setup({ capabilities = capabilities }) + end, +} diff --git a/lua/toolchain/go/plugins.lua b/lua/toolchain/go/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/go/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/go/requirements.lua b/lua/toolchain/go/requirements.lua new file mode 100644 index 0000000..34dfa88 --- /dev/null +++ b/lua/toolchain/go/requirements.lua @@ -0,0 +1,17 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.go.formatter').plugins), + table.unpack(require('toolchain.go.actions').plugins), + table.unpack(require('toolchain.go.diagnostics').plugins), + table.unpack(require('toolchain.go.debugger').plugins), + table.unpack(require('toolchain.go.plugins')), + }, + highlighters = { + 'go', + 'gomod', + 'gosum', + 'gotmpl', + }, + language_servers = require('toolchain.go.language_server').requirements, +} diff --git a/lua/toolchain/lua/actions.lua b/lua/toolchain/lua/actions.lua new file mode 100644 index 0000000..b6fa425 --- /dev/null +++ b/lua/toolchain/lua/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/lua/debugger.lua b/lua/toolchain/lua/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/lua/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/lua/diagnostics.lua b/lua/toolchain/lua/diagnostics.lua new file mode 100644 index 0000000..63c06c7 --- /dev/null +++ b/lua/toolchain/lua/diagnostics.lua @@ -0,0 +1,9 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.selene, + } + end, +} diff --git a/lua/toolchain/lua/formatter.lua b/lua/toolchain/lua/formatter.lua new file mode 100644 index 0000000..d80d040 --- /dev/null +++ b/lua/toolchain/lua/formatter.lua @@ -0,0 +1,9 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.formatting.stylua, + } + end, +} diff --git a/lua/toolchain/lua/init.lua b/lua/toolchain/lua/init.lua new file mode 100644 index 0000000..1e4ef21 --- /dev/null +++ b/lua/toolchain/lua/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.lua.requirements'), + language_servers = require('toolchain.lua.language_server'), + formatters = require('toolchain.lua.formatter'), + actions = require('toolchain.lua.actions'), + diagnostics = require('toolchain.lua.diagnostics'), + debuggers = require('toolchain.lua.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/lua/language_server.lua b/lua/toolchain/lua/language_server.lua new file mode 100644 index 0000000..5ded34e --- /dev/null +++ b/lua/toolchain/lua/language_server.lua @@ -0,0 +1,18 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'lua_ls', + }, + setup = function(lspconfig, capabilities) + lspconfig.lua_ls.setup({ + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + globals = { 'vim' }, + }, + }, + }, + }) + end, +} diff --git a/lua/toolchain/lua/plugins.lua b/lua/toolchain/lua/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/lua/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/lua/requirements.lua b/lua/toolchain/lua/requirements.lua new file mode 100644 index 0000000..437184c --- /dev/null +++ b/lua/toolchain/lua/requirements.lua @@ -0,0 +1,15 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.lua.formatter').plugins), + table.unpack(require('toolchain.lua.actions').plugins), + table.unpack(require('toolchain.lua.diagnostics').plugins), + table.unpack(require('toolchain.lua.debugger').plugins), + table.unpack(require('toolchain.lua.plugins')), + }, + highlighters = { + 'lua', + 'luadoc', + }, + language_servers = require('toolchain.lua.language_server').requirements, +} diff --git a/lua/toolchain/php/actions.lua b/lua/toolchain/php/actions.lua new file mode 100644 index 0000000..b6fa425 --- /dev/null +++ b/lua/toolchain/php/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/php/debugger.lua b/lua/toolchain/php/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/php/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/php/diagnostics.lua b/lua/toolchain/php/diagnostics.lua new file mode 100644 index 0000000..fcec5f9 --- /dev/null +++ b/lua/toolchain/php/diagnostics.lua @@ -0,0 +1,11 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.phpstan, + null_ls.builtins.diagnostics.phpcs, + null_ls.builtins.diagnostics.twigcs, + } + end, +} diff --git a/lua/toolchain/php/formatter.lua b/lua/toolchain/php/formatter.lua new file mode 100644 index 0000000..390e615 --- /dev/null +++ b/lua/toolchain/php/formatter.lua @@ -0,0 +1,12 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.formatting.phpcsfixer.with({ + prefer_local = 'vendor/bin/php-cs-fixer', + args = { 'fix', '--allow-risky=yes', '$FILENAME' }, + }), + } + end, +} diff --git a/lua/toolchain/php/init.lua b/lua/toolchain/php/init.lua new file mode 100644 index 0000000..0768d7f --- /dev/null +++ b/lua/toolchain/php/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.php.requirements'), + language_servers = require('toolchain.php.language_server'), + formatters = require('toolchain.php.formatter'), + actions = require('toolchain.php.actions'), + diagnostics = require('toolchain.php.diagnostics'), + debuggers = require('toolchain.php.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/php/language_server.lua b/lua/toolchain/php/language_server.lua new file mode 100644 index 0000000..bfc4abb --- /dev/null +++ b/lua/toolchain/php/language_server.lua @@ -0,0 +1,13 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'phpactor', + 'twiggy_language_server', + 'stimulus_ls', + }, + setup = function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.phpactor.setup(config) + lspconfig.stimulus_ls.setup(config) + end, +} diff --git a/lua/toolchain/php/plugins.lua b/lua/toolchain/php/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/php/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/php/requirements.lua b/lua/toolchain/php/requirements.lua new file mode 100644 index 0000000..469d8c2 --- /dev/null +++ b/lua/toolchain/php/requirements.lua @@ -0,0 +1,16 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.php.formatter').plugins), + table.unpack(require('toolchain.php.actions').plugins), + table.unpack(require('toolchain.php.diagnostics').plugins), + table.unpack(require('toolchain.php.debugger').plugins), + table.unpack(require('toolchain.php.plugins')), + }, + highlighters = { + 'php', + 'phpdoc', + 'twig', + }, + language_servers = require('toolchain.php.language_server').requirements, +} diff --git a/lua/toolchain/scripts/actions.lua b/lua/toolchain/scripts/actions.lua new file mode 100644 index 0000000..b6fa425 --- /dev/null +++ b/lua/toolchain/scripts/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(_null_ls) return {} end, +} diff --git a/lua/toolchain/scripts/debugger.lua b/lua/toolchain/scripts/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/scripts/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/scripts/diagnostics.lua b/lua/toolchain/scripts/diagnostics.lua new file mode 100644 index 0000000..4536ffe --- /dev/null +++ b/lua/toolchain/scripts/diagnostics.lua @@ -0,0 +1,11 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.actionlint, + null_ls.builtins.diagnostics.checkmake, + null_ls.builtins.diagnostics.dotenv_linter, + } + end, +} diff --git a/lua/toolchain/scripts/formatter.lua b/lua/toolchain/scripts/formatter.lua new file mode 100644 index 0000000..641b12d --- /dev/null +++ b/lua/toolchain/scripts/formatter.lua @@ -0,0 +1,10 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.formatting.shfmt, + null_ls.builtins.formatting.shellharden, + } + end, +} diff --git a/lua/toolchain/scripts/init.lua b/lua/toolchain/scripts/init.lua new file mode 100644 index 0000000..37a3395 --- /dev/null +++ b/lua/toolchain/scripts/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.scripts.requirements'), + language_servers = require('toolchain.scripts.language_server'), + formatters = require('toolchain.scripts.formatter'), + actions = require('toolchain.scripts.actions'), + diagnostics = require('toolchain.scripts.diagnostics'), + debuggers = require('toolchain.scripts.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/scripts/language_server.lua b/lua/toolchain/scripts/language_server.lua new file mode 100644 index 0000000..8683d52 --- /dev/null +++ b/lua/toolchain/scripts/language_server.lua @@ -0,0 +1,10 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'bashls', + }, + setup = function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.bashls.setup(config) + end, +} diff --git a/lua/toolchain/scripts/plugins.lua b/lua/toolchain/scripts/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/scripts/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/scripts/requirements.lua b/lua/toolchain/scripts/requirements.lua new file mode 100644 index 0000000..3ef696f --- /dev/null +++ b/lua/toolchain/scripts/requirements.lua @@ -0,0 +1,17 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.scripts.formatter').plugins), + table.unpack(require('toolchain.scripts.actions').plugins), + table.unpack(require('toolchain.scripts.diagnostics').plugins), + table.unpack(require('toolchain.scripts.debugger').plugins), + table.unpack(require('toolchain.scripts.plugins')), + }, + highlighters = { + 'bash', + 'make', + 'just', + 'dockerfile', + }, + language_servers = require('toolchain.scripts.language_server').requirements, +} diff --git a/lua/toolchain/text/actions.lua b/lua/toolchain/text/actions.lua new file mode 100644 index 0000000..7357cdc --- /dev/null +++ b/lua/toolchain/text/actions.lua @@ -0,0 +1,9 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.code_actions.proselint, + } + end, +} diff --git a/lua/toolchain/text/debugger.lua b/lua/toolchain/text/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/text/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/text/diagnostics.lua b/lua/toolchain/text/diagnostics.lua new file mode 100644 index 0000000..69c140e --- /dev/null +++ b/lua/toolchain/text/diagnostics.lua @@ -0,0 +1,11 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.alex, + null_ls.builtins.diagnostics.codespell, + null_ls.builtins.diagnostics.trail_space, + } + end, +} diff --git a/lua/toolchain/text/formatter.lua b/lua/toolchain/text/formatter.lua new file mode 100644 index 0000000..55aaddc --- /dev/null +++ b/lua/toolchain/text/formatter.lua @@ -0,0 +1,9 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.markdownlint, + } + end, +} diff --git a/lua/toolchain/text/init.lua b/lua/toolchain/text/init.lua new file mode 100644 index 0000000..b7ebc35 --- /dev/null +++ b/lua/toolchain/text/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.text.requirements'), + language_servers = require('toolchain.text.language_server'), + formatters = require('toolchain.text.formatter'), + actions = require('toolchain.text.actions'), + diagnostics = require('toolchain.text.diagnostics'), + debuggers = require('toolchain.text.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/text/language_server.lua b/lua/toolchain/text/language_server.lua new file mode 100644 index 0000000..f5a7aa1 --- /dev/null +++ b/lua/toolchain/text/language_server.lua @@ -0,0 +1,10 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'marksman', + }, + setup = function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.marksman.setup(config) + end, +} diff --git a/lua/toolchain/text/plugins.lua b/lua/toolchain/text/plugins.lua new file mode 100644 index 0000000..de2ce13 --- /dev/null +++ b/lua/toolchain/text/plugins.lua @@ -0,0 +1,36 @@ +return { + { + 'mrjones2014/mdpreview.nvim', + ft = 'markdown', + dependencies = { + 'norcalli/nvim-terminal.lua', + }, + config = function() + require('mdpreview').setup({ + cli_args = { + 'glow', + '-s', + '~/.config/glow/catppuccin-macchiato.json', + '-w', + '1', + '--local', + }, + renderer = { + opts = { + win_opts = { + number = true, + wrap = false, + }, + }, + }, + }) + + vim.keymap.set( + 'n', + 'mp', + ':Mdpreview', + { desc = 'Show Markdown Preview' } + ) + end, + }, +} diff --git a/lua/toolchain/text/requirements.lua b/lua/toolchain/text/requirements.lua new file mode 100644 index 0000000..1cca856 --- /dev/null +++ b/lua/toolchain/text/requirements.lua @@ -0,0 +1,14 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.text.formatter').plugins), + table.unpack(require('toolchain.text.actions').plugins), + table.unpack(require('toolchain.text.diagnostics').plugins), + table.unpack(require('toolchain.text.debugger').plugins), + table.unpack(require('toolchain.text.plugins')), + }, + highlighters = { + 'markdown', + }, + language_servers = require('toolchain.text.language_server').requirements, +} diff --git a/lua/toolchain/web/actions.lua b/lua/toolchain/web/actions.lua new file mode 100644 index 0000000..b3d7c92 --- /dev/null +++ b/lua/toolchain/web/actions.lua @@ -0,0 +1,5 @@ +---@type ToolchainActions +return { + plugins = {}, + setup = function(null_ls) return {} end, +} diff --git a/lua/toolchain/web/debugger.lua b/lua/toolchain/web/debugger.lua new file mode 100644 index 0000000..0193251 --- /dev/null +++ b/lua/toolchain/web/debugger.lua @@ -0,0 +1,4 @@ +---@type ToolchainDebuggers +return { + plugins = {}, +} diff --git a/lua/toolchain/web/diagnostics.lua b/lua/toolchain/web/diagnostics.lua new file mode 100644 index 0000000..9d9073d --- /dev/null +++ b/lua/toolchain/web/diagnostics.lua @@ -0,0 +1,9 @@ +---@type ToolchainDiagnostics +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.diagnostics.stylelint, + } + end, +} diff --git a/lua/toolchain/web/formatter.lua b/lua/toolchain/web/formatter.lua new file mode 100644 index 0000000..5d54b94 --- /dev/null +++ b/lua/toolchain/web/formatter.lua @@ -0,0 +1,11 @@ +---@type ToolchainFormatters +return { + plugins = {}, + setup = function(null_ls) + return { + null_ls.builtins.formatting.prettier.with({ + command = 'prettierd', + }), + } + end, +} diff --git a/lua/toolchain/web/init.lua b/lua/toolchain/web/init.lua new file mode 100644 index 0000000..bc202d7 --- /dev/null +++ b/lua/toolchain/web/init.lua @@ -0,0 +1,10 @@ +---@type Toolchain +return { + requirements = require('toolchain.web.requirements'), + language_servers = require('toolchain.web.language_server'), + formatters = require('toolchain.web.formatter'), + actions = require('toolchain.web.actions'), + diagnostics = require('toolchain.web.diagnostics'), + debuggers = require('toolchain.web.debugger'), + should_init = function() return true end, +} diff --git a/lua/toolchain/web/language_server.lua b/lua/toolchain/web/language_server.lua new file mode 100644 index 0000000..5af59f1 --- /dev/null +++ b/lua/toolchain/web/language_server.lua @@ -0,0 +1,20 @@ +---@type ToolchainLanguageServers +return { + requirements = { + 'html', + 'emmet_ls', + 'cssls', + 'tailwindcss', + 'eslint', + 'tsserver', + }, + setup = function(lspconfig, capabilities) + local config = { capabilities = capabilities } + lspconfig.html.setup(config) + lspconfig.emmet_ls.setup(config) + lspconfig.cssls.setup(config) + lspconfig.tailwindcss.setup(config) + lspconfig.tsserver.setup(config) + lspconfig.eslint.setup(config) + end, +} diff --git a/lua/toolchain/web/plugins.lua b/lua/toolchain/web/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/toolchain/web/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/toolchain/web/requirements.lua b/lua/toolchain/web/requirements.lua new file mode 100644 index 0000000..956f9d1 --- /dev/null +++ b/lua/toolchain/web/requirements.lua @@ -0,0 +1,18 @@ +---@type ToolchainRequirements +return { + plugins = { + table.unpack(require('toolchain.web.formatter').plugins), + table.unpack(require('toolchain.web.actions').plugins), + table.unpack(require('toolchain.web.diagnostics').plugins), + table.unpack(require('toolchain.web.debugger').plugins), + table.unpack(require('toolchain.web.plugins')), + }, + highlighters = { + 'html', + 'css', + 'scss', + 'javascript', + 'typescript', + }, + language_servers = require('toolchain.web.language_server').requirements, +} diff --git a/lua/util/finder.lua b/lua/util/finder.lua new file mode 100644 index 0000000..a6f04c6 --- /dev/null +++ b/lua/util/finder.lua @@ -0,0 +1,112 @@ +local Finder = {} + +local function is_ignored(entry, ignore_dot_dirs, ignored_dirs) + if entry == ".." or entry == "." then + return true + end + + if ignore_dot_dirs and string.match(entry, "^%.") then + return true + end + + for _, dir in ipairs(ignored_dirs) do + if entry == dir or string.find(entry, dir, 1, true) then + return true + end + end + + return false +end + +local function read_dir(dir) + local handle = io.popen('ls -a "' .. dir .. '"') + if not handle then + return nil + end + local result = handle:read("*a") + handle:close() + return result +end + +local function is_dir(path) + local f = io.open(path, "r") + if f == nil then + return false + end + local _, _, code = f:read(1) + f:close() + return code == 21 +end + +local function find_path_recursive(_dir, options) + -- Check max Depth + if options.current_depth > options.max_depth then + return nil + end + + local entries = read_dir(_dir) + if entries == nil then + return nil + end + + for entry in string.gmatch(entries, "[^\r\n]+") do + -- Check Ignored + if is_ignored(entry, options.ignore_dot_dirs, options.ignored_dirs) then + goto continue + end + + local full_path = _dir .. "/" .. entry + + -- Check for File + if entry == options.needle_file then + return full_path + end + + -- Check is Dir + if not is_dir(full_path) then + goto continue + end + + -- Recursive Call + options.current_depth = options.current_depth + 1 + local result = find_path_recursive(full_path, options) + if result ~= nil then + return result + end + + -- Cleanup + options.current_depth = options.current_depth - 1 + :: continue :: + end + return nil +end + +function Finder.get_opened_folder() + local cwd = vim.fn.getcwd() + local file_path = vim.fn.expand('%:p:h') + + if file_path ~= '' then + return file_path + end + return cwd +end + +function Finder.find_project_dir(needle_file, max_depth, priority_dirs, ignored_dirs, ignore_dot_dirs) + local options = { + needle_file = needle_file, + max_depth = max_depth, + priority_dirs = priority_dirs, + ignored_dirs = ignored_dirs, + ignore_dot_dirs = ignore_dot_dirs, + current_depth = 0 + } + + local dir = Finder.get_opened_folder() + local file = find_path_recursive(dir, options) + if file == nil then + return nil + end + return file:match("(.*/)") +end + +return Finder diff --git a/lua/util/toolchain.lua b/lua/util/toolchain.lua new file mode 100644 index 0000000..199856a --- /dev/null +++ b/lua/util/toolchain.lua @@ -0,0 +1,72 @@ +---@class Toolchain +---@field should_init fun():boolean +---@field requirements ToolchainRequirements +---@field formatters ToolchainFormatters +---@field language_servers ToolchainLanguageServers +---@field actions ToolchainActions +---@field diagnostics ToolchainDiagnostics +---@field debuggers ToolchainDebuggers + +---@class ToolchainRequirements +---@field plugins LazySpec +---@field highlighters table +---@field language_servers table + +---@class ToolchainLanguageServers +---@field requirements string[] +---@field setup fun(lspconfig:any, capabilities: any) + +---@class ToolchainFormatters +---@field plugins LazySpec[] +---@field setup fun(null_ls: any):table + +---@class ToolchainActions +---@field plugins LazySpec[] +---@field setup fun(null_ls: any):table + +---@class ToolchainDiagnostics +---@field plugins LazySpec[] +---@field setup fun(null_ls: any):table + +---@class ToolchainDebuggers +---@field plugins LazySpec[] + +local TOOLCHAIN = { + ---@type LazySpec[] + plugins = {}, + ---@type string[] + highlighters = {}, + ---@type string[] + lsp_requriemts = {}, + ---@type (fun(lspconfig, capabilities))[] + lsp_setups = {}, + ---@type (fun(null_ls):any)[] + null_ls = {}, +} + +local path = vim.fn.stdpath('config') .. '/lua/toolchain' + +for _, moduleName in ipairs(vim.fn.readdir(path)) do + local submodulePath = 'toolchain' .. '.' .. moduleName + + ---@type Toolchain + local module = require(submodulePath) + + if module.should_init() then + for _, plugin in pairs(module.requirements.plugins) do + table.insert(TOOLCHAIN.plugins, plugin) + end + for _, hl in pairs(module.requirements.highlighters) do + table.insert(TOOLCHAIN.highlighters, hl) + end + for _, lsp in pairs(module.requirements.language_servers) do + table.insert(TOOLCHAIN.lsp_requriemts, lsp) + end + table.insert(TOOLCHAIN.lsp_setups, module.language_servers.setup) + table.insert(TOOLCHAIN.null_ls, module.formatters.setup) + table.insert(TOOLCHAIN.null_ls, module.actions.setup) + table.insert(TOOLCHAIN.null_ls, module.diagnostics.setup) + end +end + +return TOOLCHAIN diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..197d5e3 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,7 @@ +column_width = 80 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 4 +quote_style = "AutoPreferSingle" +call_parentheses = "Always" +collapse_simple_statement = "FunctionOnly"