neovim conf part 3

This commit is contained in:
RafayAhmad7548 2025-04-29 07:38:49 +05:00
parent 6f23ebd0f5
commit ac7ba4097d
16 changed files with 773 additions and 462 deletions

View file

@ -4,15 +4,18 @@
"blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" },
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
"gitsigns.nvim": { "branch": "main", "commit": "ee7e50dfbdf49e3acfa416fd3ad3abbdb658582c" },
"image.nvim": { "branch": "master", "commit": "c40215d7d7d1d8c823ee9a77be1a894d5c8df41b" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
"lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "1255518cb067e038a4755f5cb3e980f79b6ab89c" },
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
"molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" },
"nvim-lspconfig": { "branch": "master", "commit": "8b0f47d851ee5343d38fe194a06ad16b9b9bd086" },
"nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" },
"nvim-web-devicons": { "branch": "master", "commit": "68f70df44652d310d2adedf181b174c33a693665" },
"oil.nvim": { "branch": "master", "commit": "685cdb4ffa74473d75a1b97451f8654ceeab0f4a" },
"onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"tabby.nvim": { "branch": "main", "commit": "6362aa9595428cefbb6556c05390e8444d1bcd12" },

View file

@ -1,4 +1,4 @@
require("config.options")
require("config.plugins")
require("config.keymaps")
require("config.autocmds")
require('config.options')
require('config.plugins')
require('config.keymaps')
require('config.autocmds')

View file

@ -13,74 +13,43 @@ vim.keymap.set({ 'v', 'o' }, '<Tab>', '>', { desc = 'tab indent ' })
vim.keymap.set({ 'v', 'o' }, '<S-Tab>', '<', { desc = 'S-tab unindent ' })
-- scrolling
vim.keymap.set({ 'n', 'v', 'o' }, '<C-d>', '<C-d>zz', { desc = 'centered scroll' })
vim.keymap.set({ 'n', 'v', 'o' }, '<C-u>', '<C-u>zz', { desc = 'centered scroll' })
vim.keymap.set({ 'n', 'v' }, '<C-d>', '<C-d>zz', { desc = 'centered scroll' })
vim.keymap.set({ 'n', 'v' }, '<C-u>', '<C-u>zz', { desc = 'centered scroll' })
-- start of line
vim.keymap.set({ 'n', 'v', 'o' }, '#', '_', { desc = '# start of line' })
-- save
-- save / quit
vim.keymap.set('n', '<C-s>', ':w<CR>', { desc = 'ctrl-s save' })
vim.keymap.set('n', '<C-w>', ':bd<CR>', { desc = 'save and close', nowait = true })
-- tabs
-- TODO: redo with telescope and ctrl tab
vim.keymap.set('n', '<leader><Tab>', ':tabnext<CR>', { desc = 'next buffer' })
vim.keymap.set('n', '<leader><S-Tab>', ':tabprev<CR>', { desc = 'previous buffer' })
vim.keymap.set('n', '<leader><S-Tab>', ':tabprev<CR>', { desc = 'previous buffer', noremap = true })
-- delete word in insert mode
vim.keymap.set('i', '<C-BS>', '<C-w>', { desc = 'delete word in insert mode' })
-- tab luasnip
-- TODO: fix this for snippets
vim.keymap.del('i', '<Tab>', { desc = 'remove keymap cause not be worky' })
-- NOTE: Right Dock: Terminal & Oil
-- NOTE: Terminal
local util = require('config.util')
vim.keymap.set('n', '<C-l>', function()
local buffers = vim.api.nvim_list_bufs()
local terminal_exists = false
for _, buf in ipairs(buffers) do
local buf_name = vim.api.nvim_buf_get_name(buf)
-- find all terminal buffers
if vim.api.nvim_buf_is_loaded(buf) and string.find(buf_name, '^term://') ~= nil then
-- find window of first terminal window if exists
local window_exists = false
local windows = vim.api.nvim_list_wins()
for _, win in ipairs(windows) do
if vim.api.nvim_win_get_buf(win) == buf then
vim.api.nvim_set_current_win(win)
window_exists = true
break
end
end
-- window dosnt exist so create and put existing terminal there
if not window_exists then
vim.cmd.vnew()
vim.api.nvim_win_set_width(0, 60)
vim.api.nvim_set_current_buf(buf)
end
terminal_exists = true
end
end
-- if no terminal then create new one
if not terminal_exists then
vim.cmd.vnew()
vim.cmd.term()
vim.api.nvim_win_set_width(0, 60)
end
vim.api.nvim_feedkeys('a', 'n', true)
end, { desc = 'open terminal', silent = true })
util.open_in_right_dock('term://')
end, { desc = 'open terminal' })
vim.keymap.set('t', '<C-j>', '<cmd>wincmd h<CR>', { desc = 'focus editor', silent = true })
vim.keymap.set('t', '<C-w>', '<C-d>', { desc = 'kill terminal' })
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { desc = 'normal mode in terminal' })
vim.keymap.set('n', '<C-e>', function()
util.open_in_right_dock('oil://')
end, { desc = 'open oil' })
-- NOTE: Windows
-- this is weird because ctrl-i => Up & ctrl-k => Down in Kitty conf
@ -90,31 +59,110 @@ vim.keymap.set({ 'n', 'v', 'o' }, '<Down><C-l>', ':wincmd l<CR>', { desc = 'movi
vim.keymap.set({ 'n', 'v', 'o' }, '<Down><C-j>', ':wincmd h<CR>', { desc = 'moving around window using ctrl-k ijkl', silent = true })
-- NOTE: Telescope --
-- NOTE: LSP
-- This function gets run when an LSP attaches to a particular buffer.
-- That is to say, every time a new file is opened that is associated with
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- function will be executed to configure the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<C-o>', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = 'Fuzzily search in current buffer' })
local mappings = {
telescope_defaults = function(actions)
return {
i = {
["<esc>"] = actions.close,
["<C-k>"] = actions.move_selection_next,
["<C-i>"] = actions.move_selection_previous,
}
}
local map = function(keys, func, desc, mode)
mode = mode or 'n'
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc, nowait = true })
end
}
return mappings
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map('<F2>', vim.lsp.buf.rename, '[R]e[n]ame')
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
map('ga', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
-- Find references for the word under your cursor.
map('gr', builtin.lsp_references, '[G]oto [R]eferences')
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
map('gi', builtin.lsp_implementations, '[G]oto [I]mplementation')
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>.
map('gd', builtin.lsp_definitions, '[G]oto [D]efinition')
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map('go', builtin.lsp_document_symbols, 'Open Document Symbols')
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
map('gO', builtin.lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
map('gt', builtin.lsp_type_definitions, '[G]oto [T]ype Definition')
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
---@param client vim.lsp.Client
---@param method vim.lsp.protocol.Method
---@param bufnr? integer some lsp support methods only in specific files
---@return boolean
local function client_supports_method(client, method, bufnr)
if vim.fn.has 'nvim-0.11' == 1 then
return client:supports_method(method, bufnr)
else
return client.supports_method(method, { bufnr = bufnr })
end
end
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd('LspDetach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
end,
})
end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints')
end
end,
})

View file

@ -31,12 +31,18 @@ vim.opt.splitbelow = true
vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
vim.opt.scrolloff = 20
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s)
-- See `:help 'confirm'`
vim.opt.confirm = true
vim.opt.fillchars:append({ eob = " " })
vim.opt.fillchars:append({ eob = ' ' })
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
-- Example for configuring Neovim to load user-installed installed Lua rocks:
package.path = package.path .. ';' .. vim.fn.expand('$HOME') .. '/.luarocks/share/lua/5.1/?/init.lua;'
package.path = package.path .. ';' .. vim.fn.expand('$HOME') .. '/.luarocks/share/lua/5.1/?.lua;'

View file

@ -0,0 +1,45 @@
-- NOTE: Revisit Later
return {
multicursor = function()
return {
{'i', 'k', mode = {'n'}},
{'<F27>', '<Cmd>MultipleCursorsAddUp<CR>', mode = {'n', 'x'}, desc = 'Add cursor and move up'},
{'<F28>', '<Cmd>MultipleCursorsAddDown<CR>', mode = {'n', 'x'}, desc = 'Add cursor and move down'},
{'<C-LeftMouse>', '<Cmd>MultipleCursorsMouseAddDelete<CR>', mode = {'n', 'i'}, desc = 'Add or remove cursor'},
-- {'<Leader>m', '<Cmd>MultipleCursorsAddVisualArea<CR>', mode = {'x'}, desc = 'Add cursors to the lines of the visual area'},
{'<Leader>a', '<Cmd>MultipleCursorsAddMatches<CR>', mode = {'n', 'x'}, desc = 'Add cursors to cword'},
{'<Leader>A', '<Cmd>MultipleCursorsAddMatchesV<CR>', mode = {'n', 'x'}, desc = 'Add cursors to cword in previous area'},
{'<C-n>', '<Cmd>MultipleCursorsAddJumpNextMatch<CR>', mode = {'n', 'x'}, desc = 'Add cursor and jump to next cword'},
-- {'q', '<Cmd>MultipleCursorsJumpNextMatch<CR>', mode = {'n', 'x'}, desc = 'Jump to next cword'},
-- {'Q', '<Cmd>MultipleCursorsJumpPrevMatch<CR>', mode = {'n', 'x'}, desc = 'Jump to next cword'},
-- {'<Leader>l', '<Cmd>MultipleCursorsLock<CR>', mode = {'n', 'x'}, desc = 'Lock virtual cursors'},
}
end,
multicursor_custom = function()
return {
{{'n', 'x' }, 'i', function()
local pos = vim.api.nvim_win_get_cursor(0)
vim.api.nvim_win_set_cursor(0, {math.max(pos[1] - 1, 1), pos[2]})
end},
{{'n', 'x' }, 'j', function()
local pos = vim.api.nvim_win_get_cursor(0)
vim.api.nvim_win_set_cursor(0, {pos[1], math.max(pos[2] - 1, 0)})
end},
{{'n', 'x' }, 'k', function()
local pos = vim.api.nvim_win_get_cursor(0)
local lines = vim.api.nvim_buf_line_count(0)
vim.api.nvim_win_set_cursor(0, {math.min(pos[1] + 1, lines), pos[2]})
end},
{{'n', 'x' }, 'h', function()
vim.cmd('startinsert')
end},
}
end
}

View file

@ -1,385 +0,0 @@
-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
if vim.v.shell_error ~= 0 then
error('Error cloning lazy.nvim:\n' .. out)
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
-- NOTE: General --
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
{ 'm4xshen/autoclose.nvim', opts = {} },
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = {} },
-- {
-- "folke/tokyonight.nvim",
-- priority = 1000,
-- config = function()
-- require('tokyonight').setup {
-- styles = {
-- comments = { italic = false }, -- Disable italics in comments
-- },
-- }
-- vim.cmd.colorscheme 'tokyonight-night'
-- end
-- },
{
'navarasu/onedark.nvim',
config = function ()
require('onedark').load()
end
},
-- NOTE: Telescope --
{
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = function()
return vim.fn.executable 'make' == 1
end,
},
},
config = function()
local actions = require('telescope.actions')
local actions_state = require('telescope.actions.state')
require('telescope').setup({
defaults = {
mappings = require('config.keymaps').telescope_defaults(actions)
},
pickers = {
find_files = {
mappings = {
i = {
["<CR>"] = function(prompt_bufnr)
local selection = actions_state.get_selected_entry()
actions.close(prompt_bufnr)
local bufname = vim.api.nvim_buf_get_name(0)
local is_empty = bufname == "" and not vim.bo.modified
if is_empty then
vim.cmd("edit" .. vim.fn.fnameescape(selection.path or selection.filename))
else
vim.cmd("tabnew " .. vim.fn.fnameescape(selection.path or selection.filename))
end
end
}
}
}
}
})
pcall(require('telescope').load_extension, 'fzf')
end
},
-- NOTE: AutoCompletions, LSP --
{
'saghen/blink.cmp',
event = 'VimEnter',
version = '1.*',
dependencies = {
{
'L3MON4D3/LuaSnip',
version = '2.*',
build = (function()
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
return
end
return 'make install_jsregexp'
end)(),
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
},
opts = {},
},
'folke/lazydev.nvim',
},
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = {
preset = 'default',
['<C-i>'] = { 'select_prev' },
['<C-k>'] = { 'select_next' },
['<Tab>'] = { 'select_and_accept', 'fallback'},
-- ['<Esc>'] = { 'hide' },
},
appearance = { nerd_font_variant = 'mono' },
completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = false, auto_show_delay_ms = 500 },
},
sources = {
default = { 'lsp', 'path', 'snippets', 'lazydev' },
providers = {
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
},
},
snippets = { preset = 'luasnip' },
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
-- which automatically downloads a prebuilt binary when enabled.
--
-- By default, we use the Lua implementation instead, but you may enable
-- the rust implementation via `'prefer_rust_with_warning'`
--
-- See :h blink-cmp-config-fuzzy for more information
fuzzy = { implementation = 'lua' },
-- Shows a signature help window while you type arguments for a function
signature = { enabled = true },
},
},
{
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
'folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
},
},
},
{ "williamboman/mason.nvim", opts = {} },
{
'neovim/nvim-lspconfig',
dependencies = {
{ "williamboman/mason.nvim", opts = {} },
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP.
{ 'j-hui/fidget.nvim', opts = {} },
-- completeions
'saghen/blink.cmp',
},
config = function()
vim.diagnostic.config {
severity_sort = true,
float = { border = 'rounded', source = 'if_many' },
underline = { severity = vim.diagnostic.severity.ERROR },
signs = vim.g.have_nerd_font and {
text = {
[vim.diagnostic.severity.ERROR] = '󰅚 ',
[vim.diagnostic.severity.WARN] = '󰀪 ',
[vim.diagnostic.severity.INFO] = '󰋽 ',
[vim.diagnostic.severity.HINT] = '󰌶 ',
},
} or {},
virtual_text = {
source = 'if_many',
spacing = 2,
format = function(diagnostic)
local diagnostic_message = {
[vim.diagnostic.severity.ERROR] = diagnostic.message,
[vim.diagnostic.severity.WARN] = diagnostic.message,
[vim.diagnostic.severity.INFO] = diagnostic.message,
[vim.diagnostic.severity.HINT] = diagnostic.message,
}
return diagnostic_message[diagnostic.severity]
end,
},
}
local capabilities = require('blink.cmp').get_lsp_capabilities()
local servers = {
-- clangd = {},
-- pyright = {},
rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
--
lua_ls = {
-- cmd = { ... },
-- filetypes = { ... },
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
}
local ensure_installed = vim.tbl_keys(servers or {})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
ensure_installed = {}, -- explicitly set to an empty table (already done using mason tool installer)
automatic_installation = false,
handlers = {
function(server_name)
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts_ls)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
}
}
end
},
-- NOTE: TreeSitter
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'rust' },
auto_install = true,
highlight = {
enable = true,
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
-- additional_vim_regex_highlighting = { 'ruby' },
},
-- indent = { enable = true, disable = { 'ruby' } },
},
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
},
-- NOTE: UI --
{
'nanozuki/tabby.nvim',
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
local theme = {
-- this is carbonfox theme
fill = 'TabLineFill',
head = { fg = '#75beff', bg = '#1c1e26' },
current_tab = { fg = '#1c1e26', bg = '#75beff' },
tab = { fg = '#c5cdd9', bg = '#1c1e26' },
win = { fg = '#1c1e26', bg = '#75beff' },
tail = { fg = '#75beff', bg = '#1c1e26' },
}
require('tabby.tabline').set(function(line)
return {
{
{ '', hl = theme.head },
line.sep('', theme.head, theme.fill),
},
line.tabs().foreach(function(tab)
local hl = tab.is_current() and theme.current_tab or theme.tab
-- remove count of wins in tab with [n+] included in tab.name()
local name = tab.name()
local index = string.find(name, "%[%d")
local tab_name = index and string.sub(name, 1, index - 1) or name
-- indicate if any of buffers in tab have unsaved changes
local modified = false
local win_ids = require('tabby.module.api').get_tab_wins(tab.id)
for _, win_id in ipairs(win_ids) do
if pcall(vim.api.nvim_win_get_buf, win_id) then
local bufid = vim.api.nvim_win_get_buf(win_id)
if vim.api.nvim_buf_get_option(bufid, "modified") then
modified = true
break
end
end
end
return {
line.sep('', hl, theme.fill),
tab_name,
modified and '',
line.sep('', hl, theme.fill),
hl = hl,
margin = ' ',
}
end),
line.spacer(),
{
line.sep('', theme.tail, theme.fill),
{ '', hl = theme.tail },
},
hl = theme.fill,
}
end)
end
},
{
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
untracked = { text = '' },
},
signs_staged = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
untracked = { text = '' },
},
signs_staged_enable = true,
signcolumn = true
}
},
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
opts = {}
}
})

View file

@ -0,0 +1,72 @@
return {
'saghen/blink.cmp',
event = 'VimEnter',
version = '1.*',
dependencies = {
{
'L3MON4D3/LuaSnip',
version = '2.*',
build = (function()
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
return
end
return 'make install_jsregexp'
end)(),
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
},
opts = {},
},
'folke/lazydev.nvim',
},
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = {
preset = 'default',
['<Tab>'] = { 'select_and_accept', 'snippet_forward', 'fallback'},
['<S-Tab>'] = { 'snippet_backward', 'fallback'},
['I'] = { 'scroll_documentation_up', 'fallback' },
['K'] = { 'scroll_documentation_down', 'fallback' },
},
appearance = { nerd_font_variant = 'mono' },
completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = false, auto_show_delay_ms = 500 },
},
sources = {
default = { 'lsp', 'path', 'snippets', 'lazydev' },
providers = {
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
},
},
snippets = { preset = 'luasnip' },
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
-- which automatically downloads a prebuilt binary when enabled.
--
-- By default, we use the Lua implementation instead, but you may enable
-- the rust implementation via `'prefer_rust_with_warning'`
--
-- See :h blink-cmp-config-fuzzy for more information
fuzzy = { implementation = 'lua' },
-- Shows a signature help window while you type arguments for a function
signature = { enabled = true },
},
}

View file

@ -0,0 +1,23 @@
return {
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
untracked = { text = '' },
},
-- signs_staged = {
-- add = { text = '┃' },
-- change = { text = '┃' },
-- delete = { text = '_' },
-- topdelete = { text = '‾' },
-- changedelete = { text = '~' },
-- untracked = { text = '┆' },
-- },
signs_staged_enable = false,
signcolumn = true
}
}

View file

@ -0,0 +1,59 @@
-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
if vim.v.shell_error ~= 0 then
error('Error cloning lazy.nvim:\n' .. out)
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
-- local keymaps = require('config.pluginmaps')
require('lazy').setup({
-- NOTE: General Editing --
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
{
'm4xshen/autoclose.nvim',
opts = {
keys = {
['%'] = { close = true, escape = true, pair = '%%', enabled_filetypes = { 'htmldjango' } },
},
options = { disable_when_touch = true, }
}
},
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = {} },
{
'lukas-reineke/indent-blankline.nvim',
main = 'ibl',
---@module 'ibl'
---@type ibl.config
opts = {},
},
require('config.plugins.oil'),
require('config.plugins.git'),
require('config.plugins.ui'),
require('config.plugins.telescope'),
require('config.plugins.blinkcmp'),
require('config.plugins.lsp'),
require('config.plugins.treesitter'),
require('config.plugins.molten'),
-- NOTE: maybe revisit this later
-- {
-- 'brenton-leighton/multiple-cursors.nvim',
-- version = '*', -- Use the latest tagged version
-- opts = {
-- custom_key_maps = keymaps.multicursor_custom()
-- }, -- This causes the plugin setup function to be called
-- keys = keymaps.multicursor(),
-- },
})

View file

@ -0,0 +1,111 @@
return {
{
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
'folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
},
},
},
{ 'williamboman/mason.nvim', opts = {} },
{
'neovim/nvim-lspconfig',
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP.
{ 'j-hui/fidget.nvim', opts = {} },
'saghen/blink.cmp',
},
config = function()
vim.diagnostic.config {
severity_sort = true,
float = { border = 'rounded', source = 'if_many' },
underline = { severity = vim.diagnostic.severity.ERROR },
signs = vim.g.have_nerd_font and {
text = {
[vim.diagnostic.severity.ERROR] = '󰅚 ',
[vim.diagnostic.severity.WARN] = '󰀪 ',
[vim.diagnostic.severity.INFO] = '󰋽 ',
},
} or {},
virtual_text = {
source = 'if_many',
spacing = 2,
format = function(diagnostic)
local diagnostic_message = {
[vim.diagnostic.severity.ERROR] = diagnostic.message,
[vim.diagnostic.severity.WARN] = diagnostic.message,
[vim.diagnostic.severity.INFO] = diagnostic.message,
[vim.diagnostic.severity.HINT] = diagnostic.message,
}
return diagnostic_message[diagnostic.severity]
end,
},
}
local capabilities = require('blink.cmp').get_lsp_capabilities()
local servers = {
-- clangd = {},
rust_analyzer = {},
pyright = {},
emmet_language_server = {},
html = { filetypes = { 'html', 'htmldjango' }, },
cssls = {},
-- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
--
lua_ls = {
-- cmd = { ... },
-- filetypes = { ... },
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
}
local ensure_installed = vim.tbl_keys(servers or {})
require('mason-lspconfig').setup {
ensure_installed = ensure_installed,
automatic_installation = false,
handlers = {
function(server_name)
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts_ls)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
}
}
-- WARN: Temoraray workaround because of naming issue i.e. djlsp and django-template-server
require('lspconfig').djlsp.setup({})
end
},
}

View file

@ -0,0 +1,28 @@
return {
{
'3rd/image.nvim',
version = '1.1.0',
build = false, -- so that it doesn't build the rock https://github.com/3rd/image.nvim/issues/91#issuecomment-2453430239
opts = {
backend = 'kitty', -- whatever backend you would like to use
max_width = 100,
max_height = 12,
max_height_window_percentage = math.huge,
max_width_window_percentage = math.huge,
window_overlap_clear_enabled = true, -- toggles images when windows are overlapped
window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '' },
}
},
{
'benlubas/molten-nvim',
version = '^1.0.0', -- use version <2.0.0 to avoid breaking changes
dependencies = { '3rd/image.nvim' },
build = ':UpdateRemotePlugins',
init = function()
-- these are examples, not defaults. Please see the readme
vim.g.molten_image_provider = 'image.nvim'
vim.g.molten_output_win_max_height = 20
end,
}
}

View file

@ -0,0 +1,48 @@
return {
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {
use_default_keymaps = false,
keymaps = {
['<C-j>'] = { '<Down><C-j>', remap = true },
['<Space>'] = { callback = function()
local oil = require('oil')
local cursor_entry = oil.get_cursor_entry()
if not cursor_entry then
return
end
if cursor_entry.type == 'directory' then
oil.select()
else
vim.cmd.wincmd('h')
local bufname = vim.api.nvim_buf_get_name(0)
local is_empty = bufname == '' and not vim.bo.modified
if is_empty then
vim.cmd(':q')
oil.select({ vertical = true, split = 'topleft' }, function()
vim.cmd.wincmd('l')
vim.api.nvim_win_set_width(0, 40)
vim.cmd.wincmd('h')
end)
else
vim.cmd.wincmd('l')
oil.select({ tab = true })
end
end
end, nowait = true },
-- shift space remapping
['<F26>'] = 'actions.parent',
}
},
-- dependencies = { { 'echasnovski/mini.icons', opts = {} } },
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
}

View file

@ -0,0 +1,64 @@
return {
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = function()
return vim.fn.executable 'make' == 1
end,
},
},
config = function()
local actions = require('telescope.actions')
local actions_state = require('telescope.actions.state')
require('telescope').setup({
defaults = {
mappings = {
i = {
['<esc>'] = actions.close,
}
}
},
pickers = {
find_files = {
mappings = {
i = {
['<CR>'] = function(prompt_bufnr)
local selection = actions_state.get_selected_entry()
actions.close(prompt_bufnr)
local bufname = vim.api.nvim_buf_get_name(0)
local is_empty = bufname == '' and not vim.bo.modified
if is_empty then
vim.cmd('edit' .. vim.fn.fnameescape(selection.path or selection.filename))
else
vim.cmd('tabnew ' .. vim.fn.fnameescape(selection.path or selection.filename))
end
end
}
}
}
}
})
pcall(require('telescope').load_extension, 'fzf')
-- NOTE: Mappings --
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<C-o>', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = 'Fuzzily search in current buffer' })
end
}

View file

@ -0,0 +1,23 @@
return {
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'css', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'rust', 'python', 'htmldjango' },
auto_install = false,
highlight = {
enable = true,
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
-- additional_vim_regex_highlighting = { 'ruby' },
},
indent = { enable = true },
},
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
}

View file

@ -0,0 +1,81 @@
return {
{
'nanozuki/tabby.nvim',
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
local theme = {
-- this is carbonfox theme
fill = 'TabLineFill',
head = { fg = '#75beff', bg = '#1c1e26' },
current_tab = { fg = '#1c1e26', bg = '#75beff' },
tab = { fg = '#c5cdd9', bg = '#1c1e26' },
win = { fg = '#1c1e26', bg = '#75beff' },
tail = { fg = '#75beff', bg = '#1c1e26' },
}
require('tabby.tabline').set(function(line)
return {
{
{ '', hl = theme.head },
line.sep('', theme.head, theme.fill),
},
line.tabs().foreach(function(tab)
local hl = tab.is_current() and theme.current_tab or theme.tab
-- remove count of wins in tab with [n+] included in tab.name()
local name = tab.name()
local index = string.find(name, '%[%d')
local tab_name = index and string.sub(name, 1, index - 1) or name
-- indicate if any of buffers in tab have unsaved changes
local modified = false
local win_ids = require('tabby.module.api').get_tab_wins(tab.id)
for _, win_id in ipairs(win_ids) do
if pcall(vim.api.nvim_win_get_buf, win_id) then
local bufid = vim.api.nvim_win_get_buf(win_id)
if vim.api.nvim_buf_get_option(bufid, 'modified') then
modified = true
break
end
end
end
return {
line.sep('', hl, theme.fill),
tab_name,
modified and '',
line.sep('', hl, theme.fill),
hl = hl,
margin = ' ',
}
end),
line.spacer(),
{
line.sep('', theme.tail, theme.fill),
{ '', hl = theme.tail },
},
hl = theme.fill,
}
end)
end
},
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
opts = {}
},
{
'navarasu/onedark.nvim',
config = function ()
require('onedark').setup({
style = 'darker',
code_style = {
comments = 'none'
}
})
require('onedark').load()
end
},
}

View file

@ -0,0 +1,85 @@
local function starts_with(str, prefix)
return string.find(str, '^' .. prefix) ~= nil
end
local function get_dock_win()
local windows = vim.api.nvim_list_wins()
for _, win in ipairs(windows) do
if vim.api.nvim_win_get_tabpage(win) == vim.api.nvim_get_current_tabpage() then
local width = vim.api.nvim_win_get_width(win)
if width == 60 or width == 40 then
return win
end
end
end
return nil
end
local function get_dock_buf(prefix)
local buffers = vim.api.nvim_list_bufs()
for _, buf in ipairs(buffers) do
if vim.api.nvim_buf_is_loaded(buf) then
local buf_name = vim.api.nvim_buf_get_name(buf)
if starts_with(buf_name, prefix) then
return buf
end
end
end
return nil
end
return {
open_in_right_dock = function (prefix)
-- set width accroding to terminal/oil
local width = prefix == 'term://' and 60 or 40
-- get dock window if exists
local dock_win = get_dock_win()
if dock_win ~= nil then
local buf = vim.api.nvim_win_get_buf(dock_win)
local buf_name = vim.api.nvim_buf_get_name(buf)
vim.api.nvim_set_current_win(dock_win)
vim.api.nvim_win_set_width(dock_win, width)
if starts_with(buf_name, prefix) then
if prefix == 'term://' then
vim.api.nvim_feedkeys('a', 'n', true)
end
else
if prefix == 'term://' then
vim.cmd.term()
vim.api.nvim_feedkeys('a', 'n', true)
else
vim.cmd('Oil')
end
end
return
end
-- no dock window at this point so create new
vim.cmd.vnew()
vim.api.nvim_win_set_width(0, width)
-- get existing buf if exists
local dock_buf = get_dock_buf(prefix)
if dock_buf ~= nil then
vim.api.nvim_set_current_buf(dock_buf)
if prefix == 'term://' then
vim.api.nvim_feedkeys('a', 'n', true)
end
return
end
if prefix == 'term://' then
vim.cmd.term()
vim.api.nvim_feedkeys('a', 'n', true)
else
vim.cmd('Oil')
end
end
}