added floating terminal and snacks

This commit is contained in:
Tawfeeq 2024-12-19 14:07:15 +01:00
parent 1f8a7a4eda
commit 4b43e2f49e
13 changed files with 672 additions and 55 deletions

View File

@ -94,6 +94,40 @@ P.S. You can delete this when you're done too. It's your config now! :)
-- vim.api.nvim_set_hl(0, 'ReturnKeyword', { fg = '#FF0000', bold = true }) -- vim.api.nvim_set_hl(0, 'ReturnKeyword', { fg = '#FF0000', bold = true })
-- Your existing Neovim configurations.. -- Your existing Neovim configurations..
vim.opt.autoread = true
vim.cmd 'autocmd VimResume * checktime'
-- Triger `autoread` when files changes on disk
-- https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
-- https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
vim.api.nvim_create_autocmd({ 'FocusGained', 'BufEnter', 'CursorHold', 'CursorHoldI' }, {
pattern = '*',
command = "if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif",
})
-- Notification after file change
-- https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
vim.api.nvim_create_autocmd({ 'FileChangedShellPost' }, {
pattern = '*',
command = "echohl WarningMsg | echo 'File changed on disk. Buffer reloaded.' | echohl None",
})
-- Trigger 'autoread' when files change on disk
-- -- Auto-read changed files when focus is gained or events occur
-- vim.api.nvim_create_autocmd({ 'FocusGained', 'BufEnter', 'CursorHold', 'CursorHoldI' }, {
-- callback = function()
-- if vim.fn.mode() ~= 'c' then
-- vim.cmd 'checktime'
-- end
-- end,
-- })
--
-- -- Notification after file change
-- vim.api.nvim_create_autocmd('FileChangedShellPost', {
-- callback = function()
-- vim.api.nvim_echo({ { 'File changed on disk. Buffer reloaded.', 'WarningMsg' } }, true, {})
-- end,
-- })
vim.lsp.inlay_hint.enable() vim.lsp.inlay_hint.enable()
vim.opt.tabstop = 4 vim.opt.tabstop = 4
vim.opt.shiftwidth = 4 vim.opt.shiftwidth = 4
@ -217,7 +251,8 @@ vim.opt.splitbelow = true
-- See `:help 'list'` -- See `:help 'list'`
-- and `:help 'listchars'` -- and `:help 'listchars'`
vim.opt.list = true vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' } -- vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
vim.opt.listchars = { tab = '', trail = '·', nbsp = '' }
-- Preview substitutions live, as you type! -- Preview substitutions live, as you type!
vim.opt.inccommand = 'split' vim.opt.inccommand = 'split'
@ -476,10 +511,28 @@ require('lazy').setup({
{ -- LSP Configuration & Plugins { -- LSP Configuration & Plugins
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
'saghen/blink.cmp',
-- Automatically install LSPs and related tools to stdpath for Neovim -- Automatically install LSPs and related tools to stdpath for Neovim
{ 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants
{ 'williamboman/mason-lspconfig.nvim' }, -- { 'williamboman/mason-lspconfig.nvim' },
{
'williamboman/mason-lspconfig.nvim',
dependencies = { 'williamboman/mason.nvim', 'neovim/nvim-lspconfig' },
config = function()
require('mason').setup()
require('mason-lspconfig').setup {
ensure_installed = { 'ts_ls', 'lua_ls', 'eslint' },
automatic_installation = true,
}
local lspconfig = require 'lspconfig'
-- Setup tsserver
lspconfig.ts_ls.setup {}
-- Setup other servers similarly
end,
},
'WhoIsSethDaniel/mason-tool-installer.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP. -- Useful status updates for LSP.
@ -503,7 +556,8 @@ require('lazy').setup({
config = function() config = function()
local lspconfig = require 'lspconfig' local lspconfig = require 'lspconfig'
local util = require 'lspconfig/util' local util = require 'lspconfig/util'
local capabilities = require('blink.cmp').get_lsp_capabilities()
require('lspconfig').lua_ls.setup { capabilities = capabilities }
-- Mason setup to ensure terraform-ls is installed -- Mason setup to ensure terraform-ls is installed
require('mason-lspconfig').setup { require('mason-lspconfig').setup {
ensure_installed = { 'terraformls', 'tflint' }, ensure_installed = { 'terraformls', 'tflint' },
@ -662,7 +716,7 @@ require('lazy').setup({
-- https://github.com/pmizio/typescript-tools.nvim -- https://github.com/pmizio/typescript-tools.nvim
-- --
-- But for many setups, the LSP (`tsserver`) will work just fine -- But for many setups, the LSP (`tsserver`) will work just fine
tsserver = {}, ts_ls = {},
-- --
lua_ls = { lua_ls = {
@ -878,8 +932,9 @@ require('lazy').setup({
-- Like many other themes, this one has different styles, and you could load -- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
-- vim.cmd.colorscheme 'kanagawa' -- vim.cmd.colorscheme 'kanagawa'
vim.cmd.colorscheme 'material-palenight'
-- vim.cmd.colorscheme 'obscure' -- vim.cmd.colorscheme 'obscure'
vim.cmd.colorscheme 'rose-pine' -- vim.cmd.colorscheme 'rose-pine'
-- You can configure highlights by doing something like: -- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none' vim.cmd.hi 'Comment gui=none'
end, end,
@ -945,6 +1000,7 @@ require('lazy').setup({
'python', 'python',
'typescript', 'typescript',
'javascript', 'javascript',
'go',
}, },
-- Autoinstall languages that are not installed -- Autoinstall languages that are not installed
auto_install = true, auto_install = true,

BIN
lazygit Executable file

Binary file not shown.

BIN
lazygit.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,220 @@
-- ~/.config/nvim/lua/custom/config/lualine_config.lua
local lualine = require 'lualine'
-- Color table for highlights
-- stylua: ignore
local colors = {
bg = '#202328',
fg = '#bbc2cf',
yellow = '#ECBE7B',
cyan = '#008080',
darkblue = '#081633',
green = '#98be65',
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67',
}
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand '%:t') ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand '%:p:h'
local gitdir = vim.fn.finddir('.git', filepath .. ';')
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
-- Config
local config = {
options = {
-- Disable sections and component separators
component_separators = '',
section_separators = '',
theme = {
-- We are going to use lualine_c and lualine_x as left and
-- right sections. Both are highlighted by the c theme.
-- So we are just setting default looks of statusline
normal = { c = { fg = colors.fg, bg = colors.bg } },
inactive = { c = { fg = colors.fg, bg = colors.bg } },
},
},
sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at the left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x at the right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function()
return ''
end,
color = { fg = colors.blue }, -- Sets highlighting of component
padding = { left = 0, right = 1 }, -- No space before this
}
ins_left {
-- mode component
function()
return ''
end,
color = function()
-- Auto change color according to Neovim's mode
local mode_color = {
n = colors.red,
i = colors.green,
v = colors.blue,
[''] = colors.blue,
V = colors.blue,
c = colors.magenta,
no = colors.red,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
ic = colors.yellow,
R = colors.violet,
Rv = colors.violet,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.red,
t = colors.red,
}
return { fg = mode_color[vim.fn.mode()] }
end,
padding = { right = 1 },
}
ins_left {
-- filesize component
'filesize',
cond = conditions.buffer_not_empty,
}
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.magenta, gui = 'bold' },
}
ins_left { 'location' }
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '' },
diagnostics_color = {
error = { fg = colors.red },
warn = { fg = colors.yellow },
info = { fg = colors.cyan },
},
}
-- Insert mid section. You can make any number of sections in Neovim :)
-- for lualine it's any number greater than 2
ins_left {
function()
return '%='
end,
}
ins_left {
-- Lsp server name
function()
local msg = 'No Active Lsp'
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end,
icon = ' LSP:',
color = { fg = '#ffffff', gui = 'bold' },
}
-- Add components to right sections
ins_right {
'o:encoding', -- option component same as &encoding in viml
fmt = string.upper, -- Convert to uppercase
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'fileformat',
fmt = string.upper,
icons_enabled = false, -- Disable icons
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'branch',
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
'diff',
-- Symbols for diff
symbols = { added = '', modified = '󰝤 ', removed = '' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
cond = conditions.hide_in_width,
}
ins_right {
function()
return ''
end,
color = { fg = colors.blue },
padding = { left = 1 },
}
-- Initialize lualine with the configuration
lualine.setup(config)

View File

@ -1,43 +0,0 @@
return { 'atelierbram/Base4Tone-nvim' }
-- vim.cmd("colorscheme base4tone_classic_a_dark")
-- or any of the other themes:
-- vim.cmd("colorscheme base4tone_classic_b_dark")
-- vim.cmd("colorscheme base4tone_classic_c_dark")
-- vim.cmd("colorscheme base4tone_classic_d_dark")
-- vim.cmd("colorscheme base4tone_classic_e_dark")
-- vim.cmd("colorscheme base4tone_classic_f_dark")
-- vim.cmd("colorscheme base4tone_classic_i_dark")
-- vim.cmd("colorscheme base4tone_classic_l_dark")
-- vim.cmd("colorscheme base4tone_classic_o_dark")
-- vim.cmd("colorscheme base4tone_classic_p_dark")
-- vim.cmd("colorscheme base4tone_classic_q_dark")
-- vim.cmd("colorscheme base4tone_classic_r_dark")
-- vim.cmd("colorscheme base4tone_classic_s_dark")
-- vim.cmd("colorscheme base4tone_classic_t_dark")
-- vim.cmd("colorscheme base4tone_classic_u_dark")
-- vim.cmd("colorscheme base4tone_classic_w_dark")
-- vim.cmd("colorscheme base4tone_modern_c_dark")
-- vim.cmd("colorscheme base4tone_modern_n_dark")
-- vim.cmd("colorscheme base4tone_modern_w_dark")
-- light
-- vim.cmd("colorscheme base4tone_classic_a_light")
-- vim.cmd("colorscheme base4tone_classic_b_light")
-- vim.cmd("colorscheme base4tone_classic_c_light")
-- vim.cmd("colorscheme base4tone_classic_d_light")
-- vim.cmd("colorscheme base4tone_classic_e_light")
-- vim.cmd("colorscheme base4tone_classic_f_light")
-- vim.cmd("colorscheme base4tone_classic_i_light")
-- vim.cmd("colorscheme base4tone_classic_l_light")
-- vim.cmd("colorscheme base4tone_classic_o_light")
-- vim.cmd("colorscheme base4tone_classic_p_light")
-- vim.cmd("colorscheme base4tone_classic_q_light")
-- vim.cmd("colorscheme base4tone_classic_r_light")
-- vim.cmd("colorscheme base4tone_classic_s_light")
-- vim.cmd("colorscheme base4tone_classic_t_light")
-- vim.cmd("colorscheme base4tone_classic_u_light")
-- vim.cmd("colorscheme base4tone_classic_w_light")
-- vim.cmd("colorscheme base4tone_modern_c_light")
-- vim.cmd("colorscheme base4tone_modern_n_light")
-- vim.cmd("colorscheme Base4Tone_Modern_w_light")

View File

@ -0,0 +1,16 @@
return {
'saghen/blink.cmp',
dependencies = 'rafamadriz/friendly-snippets',
version = 'v0.*',
opts = {
keymap = { preset = 'default' },
appearance = {
use_nvim_cmp_as_default = true,
nerd_font_variant = 'mono',
},
signature = { enabled = true },
},
}

View File

@ -0,0 +1,50 @@
vim.keymap.set('t', '<esc><esc>', '<c-\\><c-n>')
local state = {
floating = {
buf = -1,
win = -1,
},
}
local function create_floating_window(opts)
opts = opts or {}
local width = opts.width or math.floor(vim.o.columns * 0.8)
local height = opts.heighh or math.floor(vim.o.lines * 0.8)
local col = math.floor((vim.o.columns - width) / 2)
local row = math.floor((vim.o.lines - height) / 2)
local buf = nil
if vim.api.nvim_buf_is_valid(opts.buf) then
buf = opts.buf
else
buf = vim.api.nvim_create_buf(false, true)
end
local win_config = {
relative = 'editor',
width = width,
height = height,
col = col,
row = row,
style = 'minimal',
border = 'rounded',
}
local win = vim.api.nvim_open_win(buf, true, win_config)
return { buf = buf, win = win }
end
local toggle_terminal = function()
if not vim.api.nvim_win_is_valid(state.floating.win) then
state.floating = create_floating_window { buf = state.floating.buf }
if vim.bo[state.floating.buf].buftype ~= 'terminal' then
vim.cmd.terminal()
end
else
vim.api.nvim_win_hide(state.floating.win)
end
end
vim.api.nvim_create_user_command('Floaterminal', toggle_terminal, {})
vim.keymap.set({ 'n', 't' }, '<space>tt', toggle_terminal)

View File

@ -0,0 +1,14 @@
-- ~/.config/nvim/lua/custom/plugins/plugins.lua
return {
-- Custom Lualine configuration
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- Ensure icons are available
config = function()
require 'custom.config.lualine_config' -- Path to your custom Lualine config
end,
event = 'VeryLazy', -- Lazy load Lualine
priority = 1000, -- Ensure it loads before other plugins that might depend on it
},
}

View File

@ -1,3 +1,104 @@
-- ~/.config/nvim/lua/plugins.lua
return { return {
-- ... other plugins ...
-- {
'marko-cerovac/material.nvim', 'marko-cerovac/material.nvim',
-- opts = {
-- contrast = {
-- terminal = false,
-- sidebars = false,
-- floating_windows = false,
-- cursor_line = false,
-- lsp_virtual_text = false,
-- non_current_windows = false,
-- filetypes = {},
-- },
--
-- styles = {
--
-- comments = { italic = false }, -- Ensure no italics are set here
-- strings = { italic = false }, -- Ensure no italics are set here
-- keywords = { italic = false }, -- Ensure no italics are set here
-- functions = { italic = false }, -- Ensure no italics are set here
-- variables = { italic = false },
-- operators = { italic = false },
-- types = { italic = false },
-- },
--
-- plugins = {
-- -- Available plugins:
-- -- "coc",
-- -- "colorful-winsep",
-- -- "dap",
-- -- "dashboard",
-- -- "eyeliner",
-- -- "fidget",
-- -- "flash",
-- 'gitsigns',
-- -- "harpoon",
-- -- "hop",
-- -- "illuminate",
-- 'indent-blankline',
-- -- "lspsaga",
-- -- "mini",
-- -- "neogit",
-- -- "neotest",
-- 'neo-tree',
-- -- "neorg",
-- -- "noice",
-- -- "nvim-cmp",
-- -- "nvim-navic",
-- 'nvim-tree',
-- -- "nvim-web-devicons",
-- 'rainbow-delimiters',
-- -- "sneak",
-- 'telescope',
-- -- "trouble",
-- 'which-key',
-- 'nvim-notify',
-- },
--
-- disable = {
-- colored_cursor = false,
-- borders = false,
-- background = false,
-- term_colors = false,
-- eob_lines = false,
-- },
--
-- high_visibility = {
-- lighter = false,
-- darker = false,
-- },
--
-- lualine_style = 'default',
--
-- async_loading = true,
--
-- custom_colors = nil,
--
-- custom_highlights = {
-- -- Explicitly disable italics for common highlight groups
-- Comment = { italic = false },
-- String = { italic = false },
-- Keyword = { italic = false },
-- Function = { italic = false },
-- Type = { italic = false },
-- Identifier = { italic = false },
-- -- Treesitter groups
-- TSKeyword = { italic = false },
-- TSKeywordFunction = { italic = false },
-- TSKeywordOperator = { italic = false },
-- -- Add more groups as necessary
-- },
-- },
-- config = function(_, opts)
-- require('material').setup(opts)
-- vim.cmd 'colorscheme material-palenight'
-- end,
-- priority = 1000,
-- },
} }
-- ... other plugins ...

View File

@ -1 +0,0 @@
return { 'HiPhish/rainbow-delimiters.nvim' }

View File

@ -0,0 +1 @@
return { 'austinliuigi/smoke.nvim' }

View File

@ -0,0 +1,195 @@
return {
'folke/snacks.nvim',
priority = 1000,
lazy = false,
---@type snacks.Config
opts = {
bigfile = { enabled = true },
dashboard = { enabled = true },
indent = { enabled = true },
input = { enabled = true },
notifier = {
enabled = true,
timeout = 3000,
},
quickfile = { enabled = true },
scroll = { enabled = true },
statuscolumn = { enabled = true },
words = { enabled = true },
styles = {
notification = {
-- wo = { wrap = true } -- Wrap notifications
},
},
lazygit = {},
},
keys = {
{
'<leader>z',
function()
Snacks.zen()
end,
desc = 'Toggle Zen Mode',
},
{
'<leader>Z',
function()
Snacks.zen.zoom()
end,
desc = 'Toggle Zoom',
},
{
'<leader>.',
function()
Snacks.scratch()
end,
desc = 'Toggle Scratch Buffer',
},
{
'<leader>S',
function()
Snacks.scratch.select()
end,
desc = 'Select Scratch Buffer',
},
{
'<leader>n',
function()
Snacks.notifier.show_history()
end,
desc = 'Notification History',
},
{
'<leader>bd',
function()
Snacks.bufdelete()
end,
desc = 'Delete Buffer',
},
{
'<leader>cR',
function()
Snacks.rename.rename_file()
end,
desc = 'Rename File',
},
{
'<leader>gB',
function()
Snacks.gitbrowse()
end,
desc = 'Git Browse',
},
{
'<leader>gb',
function()
Snacks.git.blame_line()
end,
desc = 'Git Blame Line',
},
{
'<leader>gf',
function()
Snacks.lazygit.log_file()
end,
desc = 'Lazygit Current File History',
},
{
'<leader>gg',
function()
Snacks.lazygit()
end,
desc = 'Lazygit',
},
{
'<leader>gl',
function()
Snacks.lazygit.log()
end,
desc = 'Lazygit Log (cwd)',
},
{
'<leader>un',
function()
Snacks.notifier.hide()
end,
desc = 'Dismiss All Notifications',
},
{
'<c-/>',
function()
Snacks.terminal()
end,
desc = 'Toggle Terminal',
},
{
'<c-_>',
function()
Snacks.terminal()
end,
desc = 'which_key_ignore',
},
{
']]',
function()
Snacks.words.jump(vim.v.count1)
end,
desc = 'Next Reference',
mode = { 'n', 't' },
},
{
'[[',
function()
Snacks.words.jump(-vim.v.count1)
end,
desc = 'Prev Reference',
mode = { 'n', 't' },
},
{
'<leader>N',
desc = 'Neovim News',
function()
Snacks.win {
file = vim.api.nvim_get_runtime_file('doc/news.txt', false)[1],
width = 0.6,
height = 0.6,
wo = {
spell = false,
wrap = false,
signcolumn = 'yes',
statuscolumn = ' ',
conceallevel = 3,
},
}
end,
},
},
init = function()
vim.api.nvim_create_autocmd('User', {
pattern = 'VeryLazy',
callback = function()
-- Setup some globals for debugging (lazy-loaded)
_G.dd = function(...)
Snacks.debug.inspect(...)
end
_G.bt = function()
Snacks.debug.backtrace()
end
vim.print = _G.dd -- Override print to use snacks for `:=` command
-- Create some toggle mappings
Snacks.toggle.option('spell', { name = 'Spelling' }):map '<leader>us'
Snacks.toggle.option('wrap', { name = 'Wrap' }):map '<leader>uw'
Snacks.toggle.option('relativenumber', { name = 'Relative Number' }):map '<leader>uL'
Snacks.toggle.diagnostics():map '<leader>ud'
Snacks.toggle.line_number():map '<leader>ul'
Snacks.toggle.option('conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map '<leader>uc'
Snacks.toggle.treesitter():map '<leader>uT'
Snacks.toggle.option('background', { off = 'light', on = 'dark', name = 'Dark Background' }):map '<leader>ub'
Snacks.toggle.inlay_hints():map '<leader>uh'
Snacks.toggle.indent():map '<leader>ug'
Snacks.toggle.dim():map '<leader>uD'
end,
})
end,
}

View File

@ -1,9 +1,17 @@
return { return {
{ -- Add indentation guides even on blank lines -- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim', 'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim` -- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help ibl` -- See `:help ibl`
main = 'ibl', main = 'ibl',
opts = {}, ---@module "ibl"
---@type ibl.config
opts = {
-- debounce = 100,
indent = {
char = { '' },
},
whitespace = { highlight = { 'Whitespace', 'NonText' } },
enabled = true,
}, },
} }