diff --git a/lua/core/keymap.lua b/lua/core/keymap.lua index 5fa70cb..14f6212 100644 --- a/lua/core/keymap.lua +++ b/lua/core/keymap.lua @@ -7,11 +7,14 @@ vim.g.mapleader = ' ' vim.keymap.set('n', '', '>>') vim.keymap.set('n', '', '<<') ---[[ Markdown ]] -K.MARKDOWN_PREVIEW = { - mode = 'n', - shortcut = 'mp', - description = 'Show Markdown Preview' +--[[ Focus Shade ]] +K.FOCUS_SHADE = { + UP = { + shortcut = '', + }, + DOWN = { + shortcut = '', + }, } --[[ Git ]] @@ -19,25 +22,32 @@ K.GIT = { OPEN = { mode = 'n', shortcut = 'go', - description = 'Open Git' + description = 'Open Git', }, HUNK = { mode = 'n', shortcut = 'gh', - description = 'Toggle Inline Git Diff' + description = 'Toggle Inline Git Diff', }, BLAME = { mode = 'n', shortcut = 'gb', - description = 'Toggle Inline Git Blame' - } + description = 'Toggle Inline Git Blame', + }, } --[[ Terminal ]] K.TOGGLE_TERMINAL = { - mode = { 'n', 't' }, - shortcut = '', - description = 'Toggle Terminal' + mode = { 'n', 't' }, + shortcut = '', + description = 'Toggle Terminal', +} + +--[[ Ollam ]] +K.OLLAMA = { + mode = 'n', + shortcut = 'op', + description = 'Ollama Prompt', } --[[ Snippets ]] @@ -49,7 +59,7 @@ K.SNIPPETS = { JUMP_BACKWARDS = { mode = { 'i', 's' }, shortcut = '', - } + }, } --[[ Search ]] @@ -57,25 +67,105 @@ K.SEARCH = { FIND_FILE = { mode = 'n', shortcut = 'ff', - description = 'Find File' + description = 'Find File', }, FUZZY_FIND = { mode = 'n', shortcut = 'fz', - description = 'Fuzzy File' + description = 'Fuzzy File', }, GLOBAL_FIND_FILE = { mode = 'n', shortcut = 'gff', - description = 'Global Find File' + description = 'Global Find File', }, GLOBAL_FUZZY_FIND = { mode = 'n', shortcut = 'gfz', - description = 'Global Fuzzy File' + description = 'Global Fuzzy File', }, } ---TODO: Port the rest of the Keybindings to here +--[[ Debugging ]] +K.DEBUGGING = { + TOGGLE_UI = { + mode = 'n', + shortcut = 'dt', + description = 'Toggle Debugger UI', + }, + TOGGLE_BREAKPOINT = { + mode = 'n', + shortcut = 'db', + description = 'Toggle Breakpoint', + }, + CONTINUE = { + mode = 'n', + shortcut = 'dc', + description = 'Debugger Continue', + }, + TERMINATE = { + mode = 'n', + shortcut = 'dx', + description = 'Debugger Terminate', + }, + STEP_OVER = { + mode = 'n', + shortcut = 'ds', + description = 'Debugger Step Over', + }, +} + +--[[ File Tree ]] +K.FILE_TREE = { + TOGGLE = { + mode = 'n', + shortcut = 'ft', + description = 'Toggle File Tree', + }, + SHOW_OPEN = { + mode = 'n', + shortcut = 'fo', + description = 'Show Open Files', + }, +} + +--[[ CODE ]] +K.CODE = { + SHOW_DEFINITION = { + mode = 'n', + shortcut = 'cd', + description = 'Show Code Definition', + }, + GOTO_DEFINITION = { + mode = 'n', + shortcut = 'cgd', + description = 'Go to Definition', + }, + PEEK_DEFINITION = { + mode = 'n', + shortcut = 'cpd', + description = 'Peek Code Definition', + }, + GOTO_REFERENCES = { + mode = 'n', + shortcut = 'cgr', + description = 'Go to References', + }, + ACTIONS = { + mode = 'n', + shortcut = 'ca', + description = 'Do Code Actions', + }, + FORMAT = { + mode = 'n', + shortcut = 'cf', + description = 'Format Code', + }, + RENAME = { + mode = 'n', + shortcut = 'cr', + description = 'Rename Variable', + }, +} return K diff --git a/lua/editor/debugging.lua b/lua/editor/debugging.lua index bf66d70..4f0cf93 100644 --- a/lua/editor/debugging.lua +++ b/lua/editor/debugging.lua @@ -1,3 +1,5 @@ +local K = require('core.keymap') + return { 'mfussenegger/nvim-dap', dependencies = { @@ -35,34 +37,34 @@ return { -- Keybinding -- vim.keymap.set( - 'n', - 'dt', + K.DEBUGGING.TOGGLE_UI.mode, + K.DEBUGGING.TOGGLE_UI.shortcut, dapui.toggle, - { desc = 'Toggle Debugger UI' } + { desc = K.DEBUGGING.TOGGLE_UI.dedescriptionn } ) vim.keymap.set( - 'n', - 'db', + K.DEBUGGING.TOGGLE_BREAKPOINT.mode, + K.DEBUGGING.TOGGLE_BREAKPOINT.shortcut, dap.toggle_breakpoint, - { desc = 'Toggle Breakpoint' } + { desc = K.DEBUGGING.TOGGLE_BREAKPOINT.dedescriptionn } ) vim.keymap.set( - 'n', - 'dc', + K.DEBUGGING.CONTINUE.mode, + K.DEBUGGING.CONTINUE.shortcut, dap.continue, - { desc = 'Debugger Continue' } + { desc = K.DEBUGGING.CONTINUE.dedescriptionn } ) vim.keymap.set( - 'n', - 'dx', + K.DEBUGGING.TERMINATE.mode, + K.DEBUGGING.TERMINATE.shortcut, dap.terminate, - { desc = 'Debugger Terminate' } + { desc = K.DEBUGGING.TERMINATE.dedescriptionn } ) vim.keymap.set( - 'n', - 'ds', + K.DEBUGGING.STEP_OVER.mode, + K.DEBUGGING.STEP_OVER.shortcut, dap.step_over, - { desc = 'Debugger Step Over' } + { desc = K.DEBUGGING.STEP_OVER.dedescriptionn } ) -- Breakpoints -- diff --git a/lua/editor/file_tree.lua b/lua/editor/file_tree.lua index 25299ab..294c11e 100644 --- a/lua/editor/file_tree.lua +++ b/lua/editor/file_tree.lua @@ -1,3 +1,5 @@ +local K = require('core.keymap') + return { 'nvim-neo-tree/neo-tree.nvim', branch = 'v3.x', @@ -66,16 +68,16 @@ return { -- Keybinding -- vim.keymap.set( - 'n', - 'ft', + K.FILE_TREE.TOGGLE.mode, + K.FILE_TREE.TOGGLE.shortcut, ':Neotree toggle reveal left', - { desc = 'Toggle File Tree' } + { desc = K.FILE_TREE.TOGGLE.description } ) vim.keymap.set( - 'n', - 'fo', + K.FILE_TREE.SHOW_OPEN.mode, + K.FILE_TREE.SHOW_OPEN.shortcut, ':Neotree buffers reveal float', - { desc = 'Show Open Files' } + { desc = K.FILE_TREE.SHOW_OPEN.description } ) end, } diff --git a/lua/editor/language_server.lua b/lua/editor/language_server.lua index 63dfbeb..fc9326a 100644 --- a/lua/editor/language_server.lua +++ b/lua/editor/language_server.lua @@ -1,4 +1,5 @@ local TOOLCHAIN = require('toolchain') +local K = require('core.keymap') return { { @@ -30,28 +31,28 @@ return { -- Keybinding -- vim.keymap.set( - 'n', - 'cd', + K.CODE.SHOW_DEFINITION.mode, + K.CODE.SHOW_DEFINITION.shortcut, vim.lsp.buf.hover, - { desc = 'Show Code Definition' } + { desc = K.CODE.SHOW_DEFINITION.description } ) vim.keymap.set( - 'n', - 'gd', + K.CODE.GOTO_DEFINITION.mode, + K.CODE.GOTO_DEFINITION.shortcut, vim.lsp.buf.definition, - { desc = 'Go to Definition' } + { desc = K.CODE.GOTO_DEFINITION.description } ) vim.keymap.set( - 'n', - 'gr', + K.CODE.GOTO_REFERENCES.mode, + K.CODE.GOTO_REFERENCES.shortcut, vim.lsp.buf.references, - { desc = 'Go to References' } + { desc = K.CODE.GOTO_REFERENCES.description } ) vim.keymap.set( - 'n', - 'ca', + K.CODE.ACTIONS.mode, + K.CODE.ACTIONS.shortcut, vim.lsp.buf.code_action, - { desc = 'Do Code Actions' } + { desc = K.CODE.ACTIONS.description } ) end, }, @@ -71,10 +72,10 @@ return { -- Keybinding -- vim.keymap.set( - 'n', - 'fc', + K.CODE.FORMAT.mode, + K.CODE.FORMAT.shortcut, vim.lsp.buf.format, - { desc = 'Format Code' } + { desc = K.CODE.FORMAT.description } ) end, }, @@ -88,25 +89,25 @@ return { config = function() require('lspsaga').setup({ symbol_in_winbar = { - enable = false + enable = false, }, lightbulb = { - enable = false - } + enable = false, + }, }) -- Keybinding -- vim.keymap.set( - 'n', - 'cr', + K.CODE.RENAME.mode, + K.CODE.RENAME.shortcut, ':Lspsaga rename', - { desc = 'Rename Variable' } + { desc = K.CODE.RENAME.description } ) vim.keymap.set( - 'n', - 'cp', + K.CODE.PEEK_DEFINITION.mode, + K.CODE.PEEK_DEFINITION.shortcut, ':Lspsaga peek_definition', - { desc = 'Peek Code Definition' } + { desc = K.CODE.PEEK_DEFINITION.description } ) end, }, diff --git a/lua/editor/llm.lua b/lua/editor/llm.lua index fa8070f..c063829 100644 --- a/lua/editor/llm.lua +++ b/lua/editor/llm.lua @@ -1,3 +1,5 @@ +local K = require('core.keymap') + local explain_prompt = [[ Explain this Code short and Precise: $fname @@ -12,7 +14,7 @@ local generate_prompt = [[ ]] return { - "nomnivore/ollama.nvim", + 'nomnivore/ollama.nvim', config = function() local ollama = require('ollama') ollama.setup({ @@ -47,10 +49,10 @@ return { }) vim.keymap.set( - 'n', - 'op', + K.OLLAMA.mode, + K.OLLAMA.shortcut, ollama.prompt, - { desc = 'Ollama Prompt' } + { desc = K.OLLAMA.description } ) end, } diff --git a/lua/editor/terminal.lua b/lua/editor/terminal.lua index dabc321..3c3f7df 100644 --- a/lua/editor/terminal.lua +++ b/lua/editor/terminal.lua @@ -1,31 +1,15 @@ local K = require('core.keymap') return { - 'rebelot/terminal.nvim', + 'akinsho/toggleterm.nvim', config = function() - local terminal = require('terminal') - terminal.setup({ - layout = { - open_cmd = 'vertical new', - }, - cmd = { 'zsh' }, - autoclose = true, - }) - - local project_dir = require('util.finder').project_dir - local term - local function toggle() - if term == nil then - term = terminal.terminal:new() - term.cwd = project_dir - end - term:toggle() - end + local terminal = require('toggleterm') + terminal.setup() vim.keymap.set( K.TOGGLE_TERMINAL.mode, K.TOGGLE_TERMINAL.shortcut, - toggle, + terminal.toggle, { desc = K.TOGGLE_TERMINAL.description } ) end, diff --git a/lua/editor/theme.lua b/lua/editor/theme.lua index ecc4d4f..8fb14a0 100644 --- a/lua/editor/theme.lua +++ b/lua/editor/theme.lua @@ -1,9 +1,24 @@ +local K = require('core.keymap') + return { - 'catppuccin/nvim', - name = 'catppuccin', - priority = 1000, - config = function() - -- Set Theme -- - vim.cmd('colorscheme catppuccin') - end, + { + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1000, + config = function() + -- Set Theme -- + vim.cmd('colorscheme catppuccin') + end, + }, + { + 'sunjon/shade.nvim', + opts = { + overlay_opacity = 70, + opacity_step = 5, + keys = { + brightness_up = K.FOCUS_SHADE.UP.shortcut, + brightness_down = K.FOCUS_SHADE.DOWN.shortcut, + }, + }, + }, } diff --git a/lua/toolchain/init.lua b/lua/toolchain/init.lua index 2427e8e..7d08782 100644 --- a/lua/toolchain/init.lua +++ b/lua/toolchain/init.lua @@ -100,6 +100,7 @@ function TOOLCHAINS.init() require('toolchain.go').setup() require('toolchain.lua').setup() require('toolchain.php').setup() + require('toolchain.rust').setup() require('toolchain.scripts').setup() require('toolchain.text').setup() require('toolchain.web').setup() @@ -110,4 +111,4 @@ return TOOLCHAINS -- Type Definitions - --------------------- ---@alias SetupLSPs fun(lspconfig:any, capabilities: any) ----@alias SetupNullLsModule fun(null_ls: any):table \ No newline at end of file +---@alias SetupNullLsModule fun(null_ls: any):table diff --git a/lua/toolchain/rust.lua b/lua/toolchain/rust.lua new file mode 100644 index 0000000..66b212c --- /dev/null +++ b/lua/toolchain/rust.lua @@ -0,0 +1,52 @@ +local T = require('toolchain') +local M = {} + +function M.setup() + T.add_highlighter_autoinstalls('rust') + T.add_null_ls_module( + function(null_ls) + return { + { + name = 'clippy', + method = null_ls.methods.FORMATTING, + filetypes = { 'rust' }, + generator = require('null-ls.helpers').formatter_factory({ + command = 'rustfmt', + to_stdin = true, + input = '$TEXT', + }), + }, + } + end + ) + T.add_lsp_autoinstalls('rust_analyzer') + T.add_lsps( + function(lspconfig, capabilities) + lspconfig.rust_analyzer.setup({ + cmd = { 'ra-multiplex' }, + settings = { + ['rust-analyzer'] = { + check = { + overrideCommand = { + 'cargo', + 'clippy', + '--message-format=json-diagnostic-rendered-ansi', + '--fix', + '--allow-dirty', + }, + }, + }, + }, + }) + end + ) +end + +--[[T.add_plugins({ + 'mrcjkb/rustaceanvim', + version = '^5', -- Recommended + lazy = false, -- This plugin is already lazy + })]] +-- + +return M diff --git a/lua/toolchain/text.lua b/lua/toolchain/text.lua index 1f3b3df..19c70c2 100644 --- a/lua/toolchain/text.lua +++ b/lua/toolchain/text.lua @@ -1,5 +1,4 @@ local T = require('toolchain') -local K = require('core.keymap') local M = {} function M.setup() @@ -11,7 +10,6 @@ function M.setup() null_ls.builtins.code_actions.proselint, -- Diagnostics null_ls.builtins.diagnostics.alex, - null_ls.builtins.diagnostics.codespell, null_ls.builtins.diagnostics.trail_space, -- Formatter null_ls.builtins.diagnostics.markdownlint, @@ -24,41 +22,6 @@ function M.setup() local config = { capabilities = capabilities } lspconfig.marksman.setup(config) end) - - T.add_plugins({ - '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( - K.MARKDOWN_PREVIEW.mode, - K.MARKDOWN_PREVIEW.shortcut, - ':Mdpreview', - { desc = K.MARKDOWN_PREVIEW.description } - ) - end, - }) end return M diff --git a/lua/toolchain/web.lua b/lua/toolchain/web.lua index a3e71b3..3f498f4 100644 --- a/lua/toolchain/web.lua +++ b/lua/toolchain/web.lua @@ -2,7 +2,13 @@ local T = require('toolchain') local M = {} function M.setup() - T.add_highlighter_autoinstalls('html', 'css', 'scss', 'javascript', 'typescript') + T.add_highlighter_autoinstalls( + 'html', + 'css', + 'scss', + 'javascript', + 'typescript' + ) T.add_null_ls_module(function(null_ls) return { @@ -15,7 +21,14 @@ function M.setup() } end) - T.add_lsp_autoinstalls('html', 'emmet_ls', 'cssls', 'tailwindcss', 'eslint', 'tsserver') + T.add_lsp_autoinstalls( + 'html', + 'emmet_ls', + 'cssls', + 'tailwindcss', + 'eslint', + 'ts_ls' + ) T.add_lsps(function(lspconfig, capabilities) local config = { capabilities = capabilities } @@ -23,7 +36,7 @@ function M.setup() lspconfig.emmet_ls.setup(config) lspconfig.cssls.setup(config) lspconfig.tailwindcss.setup(config) - lspconfig.tsserver.setup(config) + lspconfig.ts_ls.setup(config) lspconfig.eslint.setup(config) end) end