1
0
Fork 1

Nvim Update

This commit is contained in:
Snoweuph 2024-11-23 17:55:23 +01:00
parent 1c7e44a338
commit 5fc2baefbe
Signed by: Snoweuph
GPG key ID: BEFC41DA223CEC55
11 changed files with 260 additions and 135 deletions

View file

@ -7,11 +7,14 @@ vim.g.mapleader = ' '
vim.keymap.set('n', '<Tab>', '>>') vim.keymap.set('n', '<Tab>', '>>')
vim.keymap.set('n', '<S-Tab>', '<<') vim.keymap.set('n', '<S-Tab>', '<<')
--[[ Markdown ]] --[[ Focus Shade ]]
K.MARKDOWN_PREVIEW = { K.FOCUS_SHADE = {
mode = 'n', UP = {
shortcut = '<Leader>mp', shortcut = '<C-Up>',
description = 'Show Markdown Preview' },
DOWN = {
shortcut = '<C-Down>',
},
} }
--[[ Git ]] --[[ Git ]]
@ -19,25 +22,32 @@ K.GIT = {
OPEN = { OPEN = {
mode = 'n', mode = 'n',
shortcut = '<Leader>go', shortcut = '<Leader>go',
description = 'Open Git' description = 'Open Git',
}, },
HUNK = { HUNK = {
mode = 'n', mode = 'n',
shortcut = '<Leader>gh', shortcut = '<Leader>gh',
description = 'Toggle Inline Git Diff' description = 'Toggle Inline Git Diff',
}, },
BLAME = { BLAME = {
mode = 'n', mode = 'n',
shortcut = '<Leader>gb', shortcut = '<Leader>gb',
description = 'Toggle Inline Git Blame' description = 'Toggle Inline Git Blame',
} },
} }
--[[ Terminal ]] --[[ Terminal ]]
K.TOGGLE_TERMINAL = { K.TOGGLE_TERMINAL = {
mode = { 'n', 't' }, mode = { 'n', 't' },
shortcut = '<F6>', shortcut = '<F6>',
description = 'Toggle Terminal' description = 'Toggle Terminal',
}
--[[ Ollam ]]
K.OLLAMA = {
mode = 'n',
shortcut = '<leader>op',
description = 'Ollama Prompt',
} }
--[[ Snippets ]] --[[ Snippets ]]
@ -49,7 +59,7 @@ K.SNIPPETS = {
JUMP_BACKWARDS = { JUMP_BACKWARDS = {
mode = { 'i', 's' }, mode = { 'i', 's' },
shortcut = '<S-Tab>', shortcut = '<S-Tab>',
} },
} }
--[[ Search ]] --[[ Search ]]
@ -57,25 +67,105 @@ K.SEARCH = {
FIND_FILE = { FIND_FILE = {
mode = 'n', mode = 'n',
shortcut = '<leader>ff', shortcut = '<leader>ff',
description = 'Find File' description = 'Find File',
}, },
FUZZY_FIND = { FUZZY_FIND = {
mode = 'n', mode = 'n',
shortcut = '<leader>fz', shortcut = '<leader>fz',
description = 'Fuzzy File' description = 'Fuzzy File',
}, },
GLOBAL_FIND_FILE = { GLOBAL_FIND_FILE = {
mode = 'n', mode = 'n',
shortcut = '<leader>gff', shortcut = '<leader>gff',
description = 'Global Find File' description = 'Global Find File',
}, },
GLOBAL_FUZZY_FIND = { GLOBAL_FUZZY_FIND = {
mode = 'n', mode = 'n',
shortcut = '<leader>gfz', shortcut = '<leader>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 = '<Leader>dt',
description = 'Toggle Debugger UI',
},
TOGGLE_BREAKPOINT = {
mode = 'n',
shortcut = '<Leader>db',
description = 'Toggle Breakpoint',
},
CONTINUE = {
mode = 'n',
shortcut = '<Leader>dc',
description = 'Debugger Continue',
},
TERMINATE = {
mode = 'n',
shortcut = '<Leader>dx',
description = 'Debugger Terminate',
},
STEP_OVER = {
mode = 'n',
shortcut = '<Leader>ds',
description = 'Debugger Step Over',
},
}
--[[ File Tree ]]
K.FILE_TREE = {
TOGGLE = {
mode = 'n',
shortcut = '<Leader>ft',
description = 'Toggle File Tree',
},
SHOW_OPEN = {
mode = 'n',
shortcut = '<Leader>fo',
description = 'Show Open Files',
},
}
--[[ CODE ]]
K.CODE = {
SHOW_DEFINITION = {
mode = 'n',
shortcut = '<Leader>cd',
description = 'Show Code Definition',
},
GOTO_DEFINITION = {
mode = 'n',
shortcut = '<Leader>cgd',
description = 'Go to Definition',
},
PEEK_DEFINITION = {
mode = 'n',
shortcut = '<Leader>cpd',
description = 'Peek Code Definition',
},
GOTO_REFERENCES = {
mode = 'n',
shortcut = '<Leader>cgr',
description = 'Go to References',
},
ACTIONS = {
mode = 'n',
shortcut = '<Leader>ca',
description = 'Do Code Actions',
},
FORMAT = {
mode = 'n',
shortcut = '<Leader>cf',
description = 'Format Code',
},
RENAME = {
mode = 'n',
shortcut = '<Leader>cr',
description = 'Rename Variable',
},
}
return K return K

View file

@ -1,3 +1,5 @@
local K = require('core.keymap')
return { return {
'mfussenegger/nvim-dap', 'mfussenegger/nvim-dap',
dependencies = { dependencies = {
@ -35,34 +37,34 @@ return {
-- Keybinding -- -- Keybinding --
vim.keymap.set( vim.keymap.set(
'n', K.DEBUGGING.TOGGLE_UI.mode,
'<Leader>dt', K.DEBUGGING.TOGGLE_UI.shortcut,
dapui.toggle, dapui.toggle,
{ desc = 'Toggle Debugger UI' } { desc = K.DEBUGGING.TOGGLE_UI.dedescriptionn }
) )
vim.keymap.set( vim.keymap.set(
'n', K.DEBUGGING.TOGGLE_BREAKPOINT.mode,
'<Leader>db', K.DEBUGGING.TOGGLE_BREAKPOINT.shortcut,
dap.toggle_breakpoint, dap.toggle_breakpoint,
{ desc = 'Toggle Breakpoint' } { desc = K.DEBUGGING.TOGGLE_BREAKPOINT.dedescriptionn }
) )
vim.keymap.set( vim.keymap.set(
'n', K.DEBUGGING.CONTINUE.mode,
'<Leader>dc', K.DEBUGGING.CONTINUE.shortcut,
dap.continue, dap.continue,
{ desc = 'Debugger Continue' } { desc = K.DEBUGGING.CONTINUE.dedescriptionn }
) )
vim.keymap.set( vim.keymap.set(
'n', K.DEBUGGING.TERMINATE.mode,
'<Leader>dx', K.DEBUGGING.TERMINATE.shortcut,
dap.terminate, dap.terminate,
{ desc = 'Debugger Terminate' } { desc = K.DEBUGGING.TERMINATE.dedescriptionn }
) )
vim.keymap.set( vim.keymap.set(
'n', K.DEBUGGING.STEP_OVER.mode,
'<Leader>ds', K.DEBUGGING.STEP_OVER.shortcut,
dap.step_over, dap.step_over,
{ desc = 'Debugger Step Over' } { desc = K.DEBUGGING.STEP_OVER.dedescriptionn }
) )
-- Breakpoints -- -- Breakpoints --

View file

@ -1,3 +1,5 @@
local K = require('core.keymap')
return { return {
'nvim-neo-tree/neo-tree.nvim', 'nvim-neo-tree/neo-tree.nvim',
branch = 'v3.x', branch = 'v3.x',
@ -66,16 +68,16 @@ return {
-- Keybinding -- -- Keybinding --
vim.keymap.set( vim.keymap.set(
'n', K.FILE_TREE.TOGGLE.mode,
'<leader>ft', K.FILE_TREE.TOGGLE.shortcut,
':Neotree toggle reveal left<CR>', ':Neotree toggle reveal left<CR>',
{ desc = 'Toggle File Tree' } { desc = K.FILE_TREE.TOGGLE.description }
) )
vim.keymap.set( vim.keymap.set(
'n', K.FILE_TREE.SHOW_OPEN.mode,
'<leader>fo', K.FILE_TREE.SHOW_OPEN.shortcut,
':Neotree buffers reveal float<CR>', ':Neotree buffers reveal float<CR>',
{ desc = 'Show Open Files' } { desc = K.FILE_TREE.SHOW_OPEN.description }
) )
end, end,
} }

View file

@ -1,4 +1,5 @@
local TOOLCHAIN = require('toolchain') local TOOLCHAIN = require('toolchain')
local K = require('core.keymap')
return { return {
{ {
@ -30,28 +31,28 @@ return {
-- Keybinding -- -- Keybinding --
vim.keymap.set( vim.keymap.set(
'n', K.CODE.SHOW_DEFINITION.mode,
'<leader>cd', K.CODE.SHOW_DEFINITION.shortcut,
vim.lsp.buf.hover, vim.lsp.buf.hover,
{ desc = 'Show Code Definition' } { desc = K.CODE.SHOW_DEFINITION.description }
) )
vim.keymap.set( vim.keymap.set(
'n', K.CODE.GOTO_DEFINITION.mode,
'<leader>gd', K.CODE.GOTO_DEFINITION.shortcut,
vim.lsp.buf.definition, vim.lsp.buf.definition,
{ desc = 'Go to Definition' } { desc = K.CODE.GOTO_DEFINITION.description }
) )
vim.keymap.set( vim.keymap.set(
'n', K.CODE.GOTO_REFERENCES.mode,
'<leader>gr', K.CODE.GOTO_REFERENCES.shortcut,
vim.lsp.buf.references, vim.lsp.buf.references,
{ desc = 'Go to References' } { desc = K.CODE.GOTO_REFERENCES.description }
) )
vim.keymap.set( vim.keymap.set(
'n', K.CODE.ACTIONS.mode,
'<leader>ca', K.CODE.ACTIONS.shortcut,
vim.lsp.buf.code_action, vim.lsp.buf.code_action,
{ desc = 'Do Code Actions' } { desc = K.CODE.ACTIONS.description }
) )
end, end,
}, },
@ -71,10 +72,10 @@ return {
-- Keybinding -- -- Keybinding --
vim.keymap.set( vim.keymap.set(
'n', K.CODE.FORMAT.mode,
'<leader>fc', K.CODE.FORMAT.shortcut,
vim.lsp.buf.format, vim.lsp.buf.format,
{ desc = 'Format Code' } { desc = K.CODE.FORMAT.description }
) )
end, end,
}, },
@ -88,25 +89,25 @@ return {
config = function() config = function()
require('lspsaga').setup({ require('lspsaga').setup({
symbol_in_winbar = { symbol_in_winbar = {
enable = false enable = false,
}, },
lightbulb = { lightbulb = {
enable = false enable = false,
} },
}) })
-- Keybinding -- -- Keybinding --
vim.keymap.set( vim.keymap.set(
'n', K.CODE.RENAME.mode,
'<leader>cr', K.CODE.RENAME.shortcut,
':Lspsaga rename<CR>', ':Lspsaga rename<CR>',
{ desc = 'Rename Variable' } { desc = K.CODE.RENAME.description }
) )
vim.keymap.set( vim.keymap.set(
'n', K.CODE.PEEK_DEFINITION.mode,
'<leader>cp', K.CODE.PEEK_DEFINITION.shortcut,
':Lspsaga peek_definition<CR>', ':Lspsaga peek_definition<CR>',
{ desc = 'Peek Code Definition' } { desc = K.CODE.PEEK_DEFINITION.description }
) )
end, end,
}, },

View file

@ -1,3 +1,5 @@
local K = require('core.keymap')
local explain_prompt = [[ local explain_prompt = [[
Explain this Code short and Precise: Explain this Code short and Precise:
$fname $fname
@ -12,7 +14,7 @@ local generate_prompt = [[
]] ]]
return { return {
"nomnivore/ollama.nvim", 'nomnivore/ollama.nvim',
config = function() config = function()
local ollama = require('ollama') local ollama = require('ollama')
ollama.setup({ ollama.setup({
@ -47,10 +49,10 @@ return {
}) })
vim.keymap.set( vim.keymap.set(
'n', K.OLLAMA.mode,
'<leader>op', K.OLLAMA.shortcut,
ollama.prompt, ollama.prompt,
{ desc = 'Ollama Prompt' } { desc = K.OLLAMA.description }
) )
end, end,
} }

View file

@ -1,31 +1,15 @@
local K = require('core.keymap') local K = require('core.keymap')
return { return {
'rebelot/terminal.nvim', 'akinsho/toggleterm.nvim',
config = function() config = function()
local terminal = require('terminal') local terminal = require('toggleterm')
terminal.setup({ 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
vim.keymap.set( vim.keymap.set(
K.TOGGLE_TERMINAL.mode, K.TOGGLE_TERMINAL.mode,
K.TOGGLE_TERMINAL.shortcut, K.TOGGLE_TERMINAL.shortcut,
toggle, terminal.toggle,
{ desc = K.TOGGLE_TERMINAL.description } { desc = K.TOGGLE_TERMINAL.description }
) )
end, end,

View file

@ -1,4 +1,7 @@
local K = require('core.keymap')
return { return {
{
'catppuccin/nvim', 'catppuccin/nvim',
name = 'catppuccin', name = 'catppuccin',
priority = 1000, priority = 1000,
@ -6,4 +9,16 @@ return {
-- Set Theme -- -- Set Theme --
vim.cmd('colorscheme catppuccin') vim.cmd('colorscheme catppuccin')
end, 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,
},
},
},
} }

View file

@ -100,6 +100,7 @@ function TOOLCHAINS.init()
require('toolchain.go').setup() require('toolchain.go').setup()
require('toolchain.lua').setup() require('toolchain.lua').setup()
require('toolchain.php').setup() require('toolchain.php').setup()
require('toolchain.rust').setup()
require('toolchain.scripts').setup() require('toolchain.scripts').setup()
require('toolchain.text').setup() require('toolchain.text').setup()
require('toolchain.web').setup() require('toolchain.web').setup()

52
lua/toolchain/rust.lua Normal file
View file

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

View file

@ -1,5 +1,4 @@
local T = require('toolchain') local T = require('toolchain')
local K = require('core.keymap')
local M = {} local M = {}
function M.setup() function M.setup()
@ -11,7 +10,6 @@ function M.setup()
null_ls.builtins.code_actions.proselint, null_ls.builtins.code_actions.proselint,
-- Diagnostics -- Diagnostics
null_ls.builtins.diagnostics.alex, null_ls.builtins.diagnostics.alex,
null_ls.builtins.diagnostics.codespell,
null_ls.builtins.diagnostics.trail_space, null_ls.builtins.diagnostics.trail_space,
-- Formatter -- Formatter
null_ls.builtins.diagnostics.markdownlint, null_ls.builtins.diagnostics.markdownlint,
@ -24,41 +22,6 @@ function M.setup()
local config = { capabilities = capabilities } local config = { capabilities = capabilities }
lspconfig.marksman.setup(config) lspconfig.marksman.setup(config)
end) 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<CR>',
{ desc = K.MARKDOWN_PREVIEW.description }
)
end,
})
end end
return M return M

View file

@ -2,7 +2,13 @@ local T = require('toolchain')
local M = {} local M = {}
function M.setup() 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) T.add_null_ls_module(function(null_ls)
return { return {
@ -15,7 +21,14 @@ function M.setup()
} }
end) 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) T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities } local config = { capabilities = capabilities }
@ -23,7 +36,7 @@ function M.setup()
lspconfig.emmet_ls.setup(config) lspconfig.emmet_ls.setup(config)
lspconfig.cssls.setup(config) lspconfig.cssls.setup(config)
lspconfig.tailwindcss.setup(config) lspconfig.tailwindcss.setup(config)
lspconfig.tsserver.setup(config) lspconfig.ts_ls.setup(config)
lspconfig.eslint.setup(config) lspconfig.eslint.setup(config)
end) end)
end end