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', '<S-Tab>', '<<')
--[[ Markdown ]]
K.MARKDOWN_PREVIEW = {
mode = 'n',
shortcut = '<Leader>mp',
description = 'Show Markdown Preview'
--[[ Focus Shade ]]
K.FOCUS_SHADE = {
UP = {
shortcut = '<C-Up>',
},
DOWN = {
shortcut = '<C-Down>',
},
}
--[[ Git ]]
@ -19,25 +22,32 @@ K.GIT = {
OPEN = {
mode = 'n',
shortcut = '<Leader>go',
description = 'Open Git'
description = 'Open Git',
},
HUNK = {
mode = 'n',
shortcut = '<Leader>gh',
description = 'Toggle Inline Git Diff'
description = 'Toggle Inline Git Diff',
},
BLAME = {
mode = 'n',
shortcut = '<Leader>gb',
description = 'Toggle Inline Git Blame'
}
description = 'Toggle Inline Git Blame',
},
}
--[[ Terminal ]]
K.TOGGLE_TERMINAL = {
mode = { 'n', 't' },
shortcut = '<F6>',
description = 'Toggle Terminal'
mode = { 'n', 't' },
shortcut = '<F6>',
description = 'Toggle Terminal',
}
--[[ Ollam ]]
K.OLLAMA = {
mode = 'n',
shortcut = '<leader>op',
description = 'Ollama Prompt',
}
--[[ Snippets ]]
@ -49,7 +59,7 @@ K.SNIPPETS = {
JUMP_BACKWARDS = {
mode = { 'i', 's' },
shortcut = '<S-Tab>',
}
},
}
--[[ Search ]]
@ -57,25 +67,105 @@ K.SEARCH = {
FIND_FILE = {
mode = 'n',
shortcut = '<leader>ff',
description = 'Find File'
description = 'Find File',
},
FUZZY_FIND = {
mode = 'n',
shortcut = '<leader>fz',
description = 'Fuzzy File'
description = 'Fuzzy File',
},
GLOBAL_FIND_FILE = {
mode = 'n',
shortcut = '<leader>gff',
description = 'Global Find File'
description = 'Global Find File',
},
GLOBAL_FUZZY_FIND = {
mode = 'n',
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

View file

@ -1,3 +1,5 @@
local K = require('core.keymap')
return {
'mfussenegger/nvim-dap',
dependencies = {
@ -35,34 +37,34 @@ return {
-- Keybinding --
vim.keymap.set(
'n',
'<Leader>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',
'<Leader>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',
'<Leader>dc',
K.DEBUGGING.CONTINUE.mode,
K.DEBUGGING.CONTINUE.shortcut,
dap.continue,
{ desc = 'Debugger Continue' }
{ desc = K.DEBUGGING.CONTINUE.dedescriptionn }
)
vim.keymap.set(
'n',
'<Leader>dx',
K.DEBUGGING.TERMINATE.mode,
K.DEBUGGING.TERMINATE.shortcut,
dap.terminate,
{ desc = 'Debugger Terminate' }
{ desc = K.DEBUGGING.TERMINATE.dedescriptionn }
)
vim.keymap.set(
'n',
'<Leader>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 --

View file

@ -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',
'<leader>ft',
K.FILE_TREE.TOGGLE.mode,
K.FILE_TREE.TOGGLE.shortcut,
':Neotree toggle reveal left<CR>',
{ desc = 'Toggle File Tree' }
{ desc = K.FILE_TREE.TOGGLE.description }
)
vim.keymap.set(
'n',
'<leader>fo',
K.FILE_TREE.SHOW_OPEN.mode,
K.FILE_TREE.SHOW_OPEN.shortcut,
':Neotree buffers reveal float<CR>',
{ desc = 'Show Open Files' }
{ desc = K.FILE_TREE.SHOW_OPEN.description }
)
end,
}

View file

@ -1,4 +1,5 @@
local TOOLCHAIN = require('toolchain')
local K = require('core.keymap')
return {
{
@ -30,28 +31,28 @@ return {
-- Keybinding --
vim.keymap.set(
'n',
'<leader>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',
'<leader>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',
'<leader>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',
'<leader>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',
'<leader>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',
'<leader>cr',
K.CODE.RENAME.mode,
K.CODE.RENAME.shortcut,
':Lspsaga rename<CR>',
{ desc = 'Rename Variable' }
{ desc = K.CODE.RENAME.description }
)
vim.keymap.set(
'n',
'<leader>cp',
K.CODE.PEEK_DEFINITION.mode,
K.CODE.PEEK_DEFINITION.shortcut,
':Lspsaga peek_definition<CR>',
{ desc = 'Peek Code Definition' }
{ desc = K.CODE.PEEK_DEFINITION.description }
)
end,
},

View file

@ -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',
'<leader>op',
K.OLLAMA.mode,
K.OLLAMA.shortcut,
ollama.prompt,
{ desc = 'Ollama Prompt' }
{ desc = K.OLLAMA.description }
)
end,
}

View file

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

View file

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

View file

@ -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
---@alias SetupNullLsModule fun(null_ls: any):table

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 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<CR>',
{ desc = K.MARKDOWN_PREVIEW.description }
)
end,
})
end
return M

View file

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