1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 03:14:55 +02:00

new nvim config

This commit is contained in:
Henrik Hautakoski 2024-08-25 16:49:58 +02:00
parent f087422bbf
commit 7d14948480
66 changed files with 1771 additions and 1719 deletions

5
nvim/README.md Normal file
View file

@ -0,0 +1,5 @@
### File structure

View file

@ -0,0 +1,7 @@
-- Hard tabs
-- vim.bo.expandtab = false
-- vim.bo.tabstop = 8
-- vim.bo.shiftwidth = 0
-- vim.bo.softtabstop = 0
require("user.utils.indent").setHardtabs()

View file

@ -0,0 +1 @@
require("user.utils.indent").setHardtabs()

View file

@ -1,35 +1,5 @@
local setup = require('setup')
-- config
require("config.options")
require("config.filetypes")
setup.keymaps('config.keymaps')
require('config.autocmd')
-- plugins
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup('plugins', {
dev = {
path = "~/code/nvim_plugins",
},
performance = {
rtp = {
disabled_plugins = {
"netrwPlugin",
-- "tutor"
}
}
}
})
-- vim: nospell
require("user.options")
require("user.keymaps")
require("user.extras")
require("user.lazy")

View file

@ -3,36 +3,28 @@
"catppuccin": { "branch": "main", "commit": "4fd72a9ab64b393c2c22b168508fd244877fec96" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "62eba813b7501b39612146cbf29cd07f1d4ac29c" },
"fd": { "branch": "master", "commit": "9cf415ccc73e633cf4ee848a347ab5635595ccf3" },
"fd": { "branch": "master", "commit": "b19136871310b01500b4f09eadd7387b8476be47" },
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"gitsigns.nvim": { "branch": "main", "commit": "562dc47189ad3c8696dbf460d38603a74d544849" },
"indent-blankline.nvim": { "branch": "master", "commit": "db926997af951da38e5004ec7b9fbdc480b48f5d" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lsp-zero.nvim": { "branch": "v3.x", "commit": "56db3d5ce5476b183783160e6045f7337ba12b83" },
"lspkind-nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" },
"lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" },
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
"mini.bufremove": { "branch": "main", "commit": "1ee294a97e091d3cf967974df622c0d887890dc2" },
"mini.nvim": { "branch": "main", "commit": "71b5694a2df4f7e3661855eb8e2814980d2e0ac9" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" },
"none-ls.nvim": { "branch": "main", "commit": "cfa65d86e21eeb60544d5e823f6db43941322a53" },
"nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
"nvim-autopairs": { "branch": "master", "commit": "19606af7c039271d5aa96bceff101e7523af3136" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lspconfig": { "branch": "master", "commit": "20906fce8587c85266b26d0b35d1bc0df2d49d58" },
"nvim-treesitter": { "branch": "master", "commit": "6699eae8ba4551fe927da0f0f3f61ae085f836aa" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "41e3abf6bfd9a9a681eb1f788bdeba91c9004b2b" },
"nvim-lspconfig": { "branch": "master", "commit": "911167921d49cd5c1c9b2436031d0da3945e787f" },
"nvim-treesitter": { "branch": "master", "commit": "e085c614fcd716eedb8e2e55bae2ccad4becd40d" },
"nvim-ts-autotag": { "branch": "main", "commit": "0cb76eea80e9c73b88880f0ca78fbd04c5bdcac7" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"oil.nvim": { "branch": "master", "commit": "a632c898fbe0e363ef89b9577f1a7714ab67d682" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "5972437de807c3bc101565175da66a1aa4f8707a" },
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
"vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" },
"which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" }
}

View file

@ -1,17 +0,0 @@
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
-- Highlight on yank
autocmd("TextYankPost", {
group = vim.api.nvim_create_augroup("highlight_yank", {}),
desc = "Hightlight selection on yank",
pattern = "*",
callback = function()
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 400 })
end,
})
-- Remove all trailing whitespaces on save
autocmd("BufWritePre", {
command = [[:exe 'norm m`' | %s/\s\+$//eg | norm ``]],
})

View file

@ -1,19 +0,0 @@
return {
-- Filetypes to enable autotag for
filetypes = {
'html',
'javascript',
'typescript',
'javascriptreact',
'typescriptreact',
'svelte',
'vue',
'tsx',
'jsx',
'rescript',
'xml',
'php',
'blade',
'markdown',
}
}

View file

@ -1,73 +0,0 @@
return function()
local cmp = require("cmp")
local utils = require("utils.cmd")
local luasnip = require("luasnip")
local lspkind = require("utils.lspkind")
local icons = require("config.icons")
local selectPrev = utils.selectPrev({ behavior = cmp.SelectBehavior.Insert })
local selectNext = utils.selectNext({ behavior = cmp.SelectBehavior.Insert })
return {
preselect = false,
completion = {
completeopt = "menu,menuone,longest,popup",
},
view = {
entries = { name = "custom", selection_order = "near_cursor" },
},
window = {
documentation = {
border = { "", "", "", "", "", "", "", " " },
},
completion = {
scrolloff = 4,
},
},
mapping = {
["<Up>"] = selectPrev,
["<S-Tab>"] = selectPrev,
["<Down>"] = selectNext,
["<Tab>"] = selectNext,
["<C-c>"] = cmp.mapping.abort(),
["<CR>"] = utils.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
formatting = {
fields = { "abbr", "kind", "menu" },
format = lspkind.format({
mode = "symbol",
preset = "codicons",
symbol_map = icons.symbols,
maxwidth = 40,
ellipsis_char = "...",
}),
},
sources = {
{ name = 'nvim_lsp_signature_help' },
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
{
name = "spell",
option = {
keep_all_entries = false,
enable_in_context = function()
return true
end,
preselect_correct_word = true,
},
},
},
-- experimental = {
-- ghost_text = {
-- hl_group = "NonText",
-- },
-- },
}
end

View file

@ -1,132 +0,0 @@
return {
flavour = "mocha",
transparent_background = true,
color_overrides = {
mocha = {
base = "#0E1019",
mantle = "#0D0F17",
crust = "#0C0D14",
surface0 = "#1a1c2d",
surface1 = "#343959",
surface2 = "#41476F",
overlay0 = "#3F4256",
overlay1 = "#5B5F7C",
overlay2 = "#767BA0",
text = "#eceef4",
},
},
no_italic = true,
no_bold = true,
highlight_overrides = {
mocha = function(colors)
return {
Visual = { bg = colors.overlay1 },
-- Floating windows
NormalFloat = { fg = colors.text, bg = colors.crust },
FloatTitle = { fg = colors.base, bg = colors.blue },
FloatBorder = { fg = colors.surface1, bg = colors.crust },
-- Window separator
WinSeparator = { fg = colors.surface0 },
NeoTreeWinSeparator = { link = "WinSeparator" },
-- Menus
Pmenu = { link = "NormalFloat" },
PmenuSel = { bg = colors.surface1 },
PmenuSbar = { link = "Pmenu" },
PmenuThumb = { link = "PmenuSel" },
-- NoiceMini = { link = "NormalFloat" },
WhichKeyFloat = { link = "Pmenu" },
-- indent lines
IblScope = { fg = colors.surface0 },
IncSearch = { bg = colors.yellow },
-- Autocomplete window
CmpItemAbbr = { fg = colors.overlay2 },
CmpItemKindText = { fg = colors.text },
-- LSP
-- LspReferenceText = { bg = colors.surface0 },
-- LspReferenceRead = { link = "LspReferenceText" },
-- LspReferenceWrite = { link = "LspReferenceText" },
--
-- -- telescope
TelescopeNormal = { link = "NormalFloat" },
TelescopeBorder = { link = "FloatBorder" },
TelescopeTitle = { link = "FloatTitle" },
TelescopePromptNormal = { bg = colors.mantle },
TelescopePromptPrefix = { fg = colors.mauve },
TelescopePromptBorder = { fg = colors.mantle, bg = colors.mantle },
TelescopePreviewTitle = { fg = colors.crust, bg = colors.mauve },
TelescopeResultsNormal = { fg = colors.overlay2, bg = colors.crust },
TelescopeMatching = { link = "CmpItemAbbrMatch" },
TelescopeSelection = { link = "PmenuSel" },
-- Statusline
StatusLine = { fg = colors.text, bg = colors.crust },
StatusLineNormal = { link = "StatusLine" },
StatusLineSeparator = { fg = colors.surface0, bg = colors.crust },
StatusLineInsert = { fg = colors.base, bg = colors.blue },
StatusLineVisual = { fg = colors.base, bg = colors.mauve },
StatusLineCommand = { fg = colors.base, bg = colors.yellow },
StatusLineReplace = { fg = colors.base, bg = colors.maroon },
-- Syntax
PreProc = { link = "Include" },
Operator = { fg = colors.rosewater },
Function = { link = "@text" },
Delimiter = { link = "@text" },
Include = { fg = colors.mauve },
Keyword = { fg = colors.yellow },
Repeat = { link = "Keyword" },
Conditional = { link = "Keyword" },
Type = { fg = colors.blue },
String = { fg = colors.lavender },
Exception = { link = "Keyword" },
["@constructor"] = { link = "Function" },
["@variable"] = { fg = colors.green },
["@variable.builtin"] = { link = "@variable" },
["@variable.parameter"] = { link = "@parameter" },
["@variable.member"] = { link = "@variable" },
["@parameter"] = { link = "@variable" },
["@keyword.function"] = { link = "Keyword" },
["@keyword.return"] = { link = "Keyword" },
["@keyword.operator"] = { link = "Keyword" },
["@property"] = { link = "@variable" },
["@tag"] = { link = "Keyword" },
["@tag.delimiter"] = { link = "@text" },
["@punctuation"] = { link = "@text" },
["@module"] = { link = "@text" },
["@punctuation.bracket"] = { link = "@punctuation" },
["@lsp.type.property"] = { link = "@variable" },
-- Markup
["@markup.raw"] = { link = "@text" },
["@markup.strong"] = { fg = colors.blue },
["@markup.italic"] = { fg = colors.green },
-- PHP specific
["@keyword.import.php"] = { link = "@keyword" },
["@class_name.php"] = { link = "@text" },
["@extend_name.php"] = { link = "@text" },
["@implement_name.php"] = { link = "@text" },
["@namespace_name.php"] = { link = "@text" },
["@namespace_alias.php"] = { link = "@text" },
}
end,
},
integrations = {
cmp = true,
treesitter = true,
-- barbar = true,
-- neotree = true,
-- noice = true,
telescope = {
enabled = true,
},
},
}

View file

@ -1,13 +0,0 @@
return {
format_options = {
async = true,
lsp_fallback = true,
},
notify_on_error = true,
formatters_by_ft = {
bash = { "shfmt" },
blade = { "blade-formatter" },
lua = { "stylua" },
["_"] = { "prettier" },
},
}

View file

@ -1,72 +0,0 @@
--
-- Filetype settings
--
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
-- Add blade filetype for .blade.php files
vim.filetype.add({
pattern = {
['.*%.blade%.php'] = 'blade',
},
})
-- PHP
autocmd('Filetype', {
pattern = 'php',
callback = function()
-- Fix autocomment plugins to use line comments
vim.cmd('setlocal commentstring=//\\%s')
-- Goto file for blade files in laravel projects
vim.cmd([[
set path=.,resources/views
set suffixesadd=.blade.php
set includeexpr=substitute(v:fname,'\\.','/','g')
]])
end
})
autocmd('Filetype', {
pattern = 'kdl',
callback = function()
vim.cmd('setlocal commentstring=//\\%s')
end
})
--
-- Indent
--
augroup('indent', { clear = true })
-- Hardtabs for make
autocmd('Filetype', {
group = 'indent',
pattern = { 'make' },
command = 'setlocal ts=4 sts=0 sw=4 noexpandtab'
})
-- Softtab (2) for yaml
autocmd('Filetype', {
group = 'indent',
pattern = { 'yaml' },
command = 'setlocal ts=2 sts=2 sw=2 expandtab'
})
-- Softtab (4) for CSS types
autocmd('Filetype', {
group = 'indent',
pattern = { 'css', 'scss', 'less' },
command = 'setlocal ts=4 sts=4 sw=4 expandtab'
})
-- Hardtabs for c/cpp
autocmd('Filetype', {
group = 'indent',
pattern = { 'c', 'cpp' },
command = 'setlocal ts=8 sts=0 sw=8 noexpandtab'
})

View file

@ -1,22 +0,0 @@
local icons = require('config.icons').diff_gutter
return {
signs = {
add = { text = icons.add },
delete = { text = icons.delete },
change = { text = icons.change },
untracked = { text = icons.untracked },
topdelete = { text = icons.delete },
changedelete = { text = icons.change },
},
signs_staged = {
add = { text = icons.add },
delete = { text = icons.delete },
change = { text = icons.change },
topdelete = { text = icons.delete },
changedelete = { text = icons.change },
},
diff_opts = {
internal = true
}
}

View file

@ -1,107 +0,0 @@
return {
prompt = '',
current = ' ',
selected = '',
close = '󰅖',
modified = '',
pinned = '',
separator = '',
edit = '',
buffer = '',
fold = {
open = '',
close = '',
sep = ' ',
},
tree = {
node = '',
nodelast = '',
},
files = {
text = "",
symlink = "",
},
folder = {
closed = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
},
diff = {
added = '',
modified = '',
removed = '',
},
diff_gutter = {
add = '',
change = '',
delete = '',
untracked = '+'
},
gitsigns = {
-- Change type
added = "",
modified = "",
deleted = "",
renamed = "",
-- Status type
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
todo = {
default = '',
warn = '',
perf = '',
bug = '',
hack = '',
test = '󰄉',
},
diagnostics = {
error = '',
warn = '',
info = '',
hint = ''
},
test = {
ok = '',
failed = '',
running = '',
skipped = '',
watch = '',
unknown = '',
},
symbols = {
Text = "TXT",
Method = "",
Function = "󰊕",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "󰑭",
Value = "",
Number = "",
NumberHex = "󱊧",
Enum = "",
Keyword = "",
Snippet = "󰘦",
Color = "",
File = "󰈙",
Reference = "󰈇",
Folder = "󰉋",
EnumMember = "",
Constant = "",
Struct = "󰙅",
Event = "",
Operator = "󰆕",
TypeParameter = "",
},
}

View file

@ -1,156 +0,0 @@
local cmd = vim.cmd
local icons = require('config.icons')
local buffers = require('utils.buffers')
local telescope = require('utils.telescope')
return {
leader = " ",
--
-- Global keymaps! Alot of stuff "borrowed" from thePrimeagen
--
global = {
{ "n", "<leader>W", "<cmd>lua vim.opt.list = not vim.opt.list._value<cr>", { silent = true, desc = "Toggle show whitespace" } },
--
-- Navigation
--
-- Make half page jumps stay in the center of screen
{ "n", "<C-u>", "<C-u>zz", { silent = true, desc = "jump half a page up" } },
{ "n", "<C-d>", "<C-d>zz", { silent = true, desc = "jump half a page down" } },
{ "n", "<S-PageUp>", "<C-u>zz", { silent = true, desc = "jump half a page up" } },
{ "n", "<S-PageDown>", "<C-d>zz", { silent = true, desc = "jump half a page down" } },
-- Split windows
{ "n", "<C-h>", "<C-w>h", { silent = true, desc = "Focus left split" } },
{ "n", "<C-j>", "<C-w>j", { silent = true, desc = "Focus down split" } },
{ "n", "<C-k>", "<C-w>k", { silent = true, desc = "Focus up split" } },
{ "n", "<C-l>", "<C-w>l", { silent = true, desc = "Focus right split" } },
-- Make jump to next search item stay in the center of screen.
{ "n", "n", "nzzzv", { silent = true, desc = "jump to next search match" } },
{ "n", "N", "Nzzzv", { silent = true, desc = "jump to previous search match" } },
-- Ctrl+s saves the current buffer in normal/insert mode.
{ { "n", "i" }, "<C-s>", cmd.w, { desc = "save current buffer" } },
-- Move text
{ "n", "<S-a>", ":m -2<CR>v=", { silent = true, desc = "move current line one line up" } },
{ "n", "<S-d>", ":m +1<CR>v=", { silent = true, desc = "move current line one line down" } },
{ "v", "<S-a>", ":m '<-2<CR>gv=gv", { silent = true, desc = "move current selection one line up" } },
{ "v", "<S-d>", ":m '>+1<CR>gv=gv", { silent = true, desc = "move current selection one line down" } },
-- copy/paste
{ "x", "<leader>p", [["_dP]],
{ silent = true, desc = "Paste over selected text without losing content in \"-register" } },
{ { "n", "v" }, "<leader>y", [["+y]], { desc = "Yank to system clipboard register" } },
{ { "n", "v" }, "<leader>p", [["+p]], { desc = "Paste from system clipboard register" } },
-- File operations
--{ "n", "gf", "<cmd>e <cfile><CR>", { silent = true, desc = "Open (or create) file under cursor" } },
{ "n", "<leader>Fc", ":CreateFile ", { silent = true, desc = "Create new file" } },
{ "n", "<leader>Fx", "<cmd>!chmod +x %<CR>", { silent = true, desc = "Set execute flag on current file" } },
-- buffers
{ "n", "<leader>bn", cmd.bn, { silent = true, desc = "Move to next buffer" } },
{ "n", "<leader>bb", cmd.bp, { silent = true, desc = "Move to previous buffer" } },
{ "n", "<leader>bd", cmd.bd, { silent = true, desc = "Close current buffer" } },
{ "n", "<leader>bc", buffers.CloseOthers, { silent = true, desc = "Close all other buffers" } },
{ "n", "<leader>bD", buffers.CloseAll, { silent = true, desc = "Close all buffers" } },
-- Indent
{ 'n', "<Tab>", "^=$" },
{ 'x', "<Tab>", "=", { desc = "auto indent selection" } },
{ "i", "<S-Tab>", "<C-d>", { desc = "delete indent" } },
{ 'n', "<leader>fs", [[:%s/\s\+$//g<CR>`']], { desc = "Remove trailing spaces" } },
-- fix paste
-- {'n', "p", "p=$"},
-- Crazy search+replace
{ "n", "<leader>rw", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
{ desc = "search+replace word under cursor" } },
-- Hex formatting
{ "x", "<leader>fhx", [[:s/\(\x\{2\}\)/0x\1, /g]], { desc = "Format hex" } },
{ "x", "<leader>fha", [[:s/0x\(\x\{1\}\X\)/0x0\1/g]], { desc = "Format each hex number to be 2 characters long" } },
{ "x", "<leader>fhn", [[:s/\(\(0x\x\{1,2\}, \)\{8\}\)/\1\r/g]], { desc = "Format hex with 8 bytes per row" } },
-- {{"x"}, "<leader>hb", [[:'<,'>s/\(\x\{2\}\)/0x\1, /g<cr>]], { desc = "Format a hex string to byte array"}},
-- Case formatting
{ "x", "<leader>fcsc", [[:s/\%V\([a-z]\+\)_\?/\u\1/g]], { desc = "Convert text from snake_case to CamelCase" } },
-- diagnostics
{ "n", "<leader>do", vim.diagnostic.open_float, { desc = "Open diagnostics" } },
{ "n", "<leader>dn", vim.diagnostic.get_next, { desc = "Goto next" } },
{ "n", "<leader>dp", vim.diagnostic.get_prev, { desc = "Goto previous" } },
-- TMux
{ "n", "<leader>m", ":terminal tmuxs<cr>i", { desc = "Open tmux manager" } },
{ "n", "Q", "<nop>" }, -- NOPE
},
whichkey = {
mode = { "n", "v", "x" },
{ "<leader>F", group = "Files" },
{ "<leader>b", group = "Buffers", icon = icons.buffer },
{ "<leader>c", group = "Code" },
{ "<leader>d", group = "Diagnostics" },
{ "<leader>f", group = "Format" },
{ "<leader>fc", group = "Case" },
{ "<leader>fcs", group = "snake_case" },
{ "<leader>fh", group = "Hex", icon = icons.symbols.NumberHex },
{ "<leader>g", group = "git" },
{ "<leader>r", group = "Rename", icon = icons.edit },
{ "<leader>s", group = "Search" },
},
oil = {
{ '<leader>.', function() require('oil').open_float() end, { desc = "Open parent directory" } }
},
conform = {
{ '<leader>ff', "<cmd>Format<cr>", desc = 'Format file' },
{ '<leader>ff', "<cmd>Format<cr>", mode = 'x', desc = 'Format selection' },
},
fugitive = {
{ '<leader>gB', '<cmd>Git blame<cr>', desc = 'Git blame' },
{ '<leader>gs', '<cmd>Git status<cr>', desc = 'Git status' },
{ '<leader>gl', '<cmd>Git log<cr>', desc = 'Git log' },
{ '<leader>gL', '<cmd>Git log %<cr>', desc = 'Git log current file' },
},
gitsigns = {
{ '<leader>gp', '<cmd>Gitsigns preview_hunk<cr>', desc = 'Git preview diff' },
{ '<leader>gb', '<cmd>Gitsigns blame_line<cr>', desc = 'Git blame line' },
{ '<leader>gr', '<cmd>Gitsigns reset_hunk<cr>', desc = 'Reset section where the cursor is' },
},
trouble = {
{ '<leader>dt', '<cmd>Trouble diagnostics toggle<cr>', desc = 'Trouble diagnostics' },
},
-- Keybinds for buffers with an LSP client attached
lsp = {
{ '<leader>ca', function() vim.lsp.buf.code_action() end, mode={'n', 'x'}, desc = 'Code action' },
{ '<leader>rs', function() vim.lsp.buf.rename() end, desc = 'Rename symbol' },
{ '<leader>sr', '<cmd>Telescope lsp_references<cr>', desc = 'Search Reference' },
{ '<leader>ss', '<cmd>Telescope lsp_document_symbols<cr>', desc = 'Search document symbols' },
{ '<leader>si', '<cmd>Telescope lsp_implementations<cr>', desc = 'Search Inplementations' },
{ '<leader>sp', '<cmd>Telescope lsp_workspace_symbols<cr>', desc = 'Search Workspace symbols' },
{ 'go', '<cmd>Telescope lsp_type_definitions<cr>', desc = "Goto type definition" },
{ 'gd', '<cmd>Telescope lsp_definitions<cr>', desc = 'Goto definition' },
},
telescope = {
{ '<leader>sf', '<cmd>Telescope find_files<cr>', desc = 'Search files' },
{ '<leader>sF', telescope.all_files, desc = 'Search all files' },
{ '<leader>sb', '<cmd>Telescope buffers<cr>', desc = 'Search buffers' },
{ '<leader>sa', '<cmd>Telescope live_grep<cr>', desc = 'Search in files' },
{ '<leader>sg', '<cmd>Telescope git_files<cr>', desc = 'Search Git files' },
{ '<leader>sG', '<cmd>Telescope git_status<cr>', desc = 'Search Git status' },
{ '<leader>so', '<cmd>Telescope oldfiles<cr>', desc = 'Search Old files' },
{ '<leader>sw', '<cmd>Telescope grep_string<cr>', desc = 'Search for word under cursor' },
{ '<leader>sd', '<cmd>Telescope diagnostics<cr>', desc = 'Search Diagnostics' },
{ '<leader>sq', '<cmd>Telescope quickfix<cr>', desc = 'Search Quickfix' },
{ '<leader>sh', '<cmd>Telescope help<cr>', desc = 'Search Neovim help' },
},
}

View file

@ -1,100 +0,0 @@
vim.g.lsp_zero_ui_float_border = vim.g.float_border or "none"
return {
document_highlight = true,
nonels = function()
local null_ls = require("null-ls")
return {
--null_ls.builtins.completion.luasnip,
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.impl,
null_ls.builtins.code_actions.gitsigns,
-- null_ls.builtins.diagnostics.phpstan,
-- null_ls.builtins.diagnostics.phpcs,
null_ls.builtins.diagnostics.checkmake,
null_ls.builtins.diagnostics.actionlint,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.dotenv_linter,
}
end,
servers = {
-- Bash
bashls = {},
-- C/C++
ccls = {},
-- PHP
-- intelephense = {},
phpactor = {
settings = {
init_options = {
["language_server_phpstan.enabled"] = true,
["language_server_psalm.enabled"] = false,
},
},
},
-- JS,TS,VUE
tsserver = {
document_highlight = false,
settings = {
tsserver_plugins = {
"@vue/typescript-plugin",
},
},
filetypes = { "javascript", "typescript", "vue" },
},
volar = {
init_options = {
vue = {
hybridMode = false,
},
},
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" },
},
-- TailwindCSS
tailwindcss = {},
-- GO
gopls = {
on_save = function()
local params = vim.lsp.util.make_range_params()
params.context = { only = { "source.organizeImports" } }
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000)
for cid, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
vim.lsp.util.apply_workspace_edit(r.edit, enc)
end
end
end
vim.lsp.buf.format({ async = false })
end,
settings = {
gopls = {
analyses = {
unusedvariable = true,
unusedwrite = true,
useany = true,
},
gofumpt = true,
},
},
},
-- Lua
lua_ls = {
cmd = { "/opt/luals/bin/lua-language-server", "--logpath=~/.local/luals/logs" },
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
},
},
},
},
},
},
}

View file

@ -1,114 +0,0 @@
local icons = require("config.icons")
local separator = { "'" .. icons.separator .. "'", color = "StatusLineSeparator" }
return {
options = {
globalstatus = true,
component_separators = "",
section_separators = "",
disabled_filetypes = {
statusline = {
"dashboard",
},
},
theme = {
normal = {
a = "StatusLineNormal",
b = "StatusLine",
c = "StatusLine",
x = "StatusLine",
y = "StatusLine",
z = "StatusLine",
},
command = {
a = "StatusLineCommand",
z = "StatusLine",
},
insert = {
a = "StatusLineInsert",
z = "StatusLine",
},
visual = {
a = "StatusLineVisual",
z = "StatusLine",
},
replace = {
a = "StatusLineReplace",
z = "StatusLine",
},
},
},
sections = {
lualine_a = {
"mode",
},
lualine_b = {
separator,
"branch",
separator,
'" " .. tostring(#vim.tbl_keys(vim.lsp.buf_get_clients()))',
{
require("lazy.status").updates,
cond = require("lazy.status").has_updates,
color = { fg = "#ff9e64" },
},
{
"diagnostics",
symbols = {
error = icons.diagnostics.error .. " ",
warn = icons.diagnostics.warn .. " ",
info = icons.diagnostics.info .. " ",
hint = icons.diagnostics.hint .. " ",
},
},
{
"diff",
symbols = {
added = icons.diff.added .. " ",
modified = icons.diff.modified .. " ",
removed = icons.diff.removed .. " ",
},
},
separator,
},
lualine_c = {
{
"filename",
path = 1,
symbols = {
modified = "+",
readonly = "[R]",
unnamed = "-",
newfile = "[New]",
},
},
},
lualine_x = {
"filetype",
"fileformat",
'(vim.bo.expandtab and "SPC" or "TAB") .. " " .. vim.bo.shiftwidth',
},
lualine_y = {
separator,
"location",
"progress",
},
lualine_z = {},
},
winbar = {
lualine_c = {
{ "filetype", icon_only = true },
"filename",
},
},
inactive_winbar = {
lualine_c = {
{ "filetype", icon_only = true },
"filename",
},
},
extensions = {
"lazy",
"neo-tree",
},
}

View file

@ -1,37 +0,0 @@
return {
default_file_explorer = true,
prompt_save_on_select_new_entry = false,
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-v>"] = "actions.select_vsplit",
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = "actions.refresh",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
["g\\"] = "actions.toggle_trash",
},
use_default_keymaps = false,
float = {
-- Padding around the floating window
padding = 2,
max_width = 200,
max_height = 30,
border = "single",
win_options = {
winblend = 0,
},
},
ssh = {
border = "single",
},
keymaps_help = {
border = "single",
}
}

View file

@ -1,129 +0,0 @@
local set = vim.opt
local icons = require('config.icons')
--
-- Variables
--
-- Custom
-- vim.g.float_border = 'single'
--
-- General Settings
--
set.termguicolors = true
-- Decrease update time
set.updatetime = 50
-- Decrease mapped sequence wait time
-- Displays which-key popup sooner
set.timeoutlen = 50
--
-- UI
--
-- disable mode in the command line, because i use lualine
set.showmode = false
set.winblend = 5 -- how much floating windows should blend with background.
set.pumblend = 5 -- popup blend
set.pumheight = 15 -- popup height
--
-- Editor settings
--
set.wrap = false -- Disable line wrap
set.laststatus = 3
set.splitkeep = "screen"
set.scrolloff = 10
-- Configure how new splits should be opened
set.splitright = true
set.splitbelow = true
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
set.list = false
set.listchars = { tab = ' »', space = '·', nbsp = '' }
set.fillchars = {
foldopen = icons.fold.open,
foldclose = icons.fold.close,
fold = " ",
foldsep = icons.fold.sep,
diff = " ",
eob = " ",
}
-- mouse and cursor
set.cursorline = true
set.mousemoveevent = true
-- search
set.hlsearch = false
set.incsearch = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
set.ignorecase = true
set.smartcase = true
-- Spell stuff, because i cant english
set.spell = true
set.spelllang = { 'en_us' }
-- line numbers
set.number = true
set.relativenumber = true
set.numberwidth = 5
-- sign column to the left
set.statuscolumn = '%s %=%{v:relnum?v:relnum:v:lnum} │ '
-- indent
set.expandtab = true
set.tabstop = 4
set.softtabstop = 4
set.shiftwidth = 4
set.autoindent = true
set.smartindent = true
-- Completion
-- set.completeopt = "menuone,longest,preview"
-- folds
set.foldenable = true
set.foldlevel = 99
set.foldmethod = "expr"
set.foldexpr = "nvim_treesitter#foldexpr()"
set.foldcolumn = "auto"
--
-- Diagnostics
--
vim.diagnostic.config({
virtual_text = false,
severity_sort = true,
underline = false,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = icons.diagnostics.error,
[vim.diagnostic.severity.WARN] = icons.diagnostics.warn,
[vim.diagnostic.severity.INFO] = icons.diagnostics.info,
[vim.diagnostic.severity.HINT] = icons.diagnostics.hint
},
},
float = {
border = { " " },
header = false,
source = true,
}
})

View file

@ -1,57 +0,0 @@
return function()
local icons = require("config.icons")
local actions = require("telescope.actions")
local path_delim = require("utils.path").delimiter()
local border = {
prompt = { " " },
results = { " " },
preview = { " " },
}
local dropdown_opts = {
previewer = false,
prompt_title = false,
layout_strategy = "horizontal",
layout_config = {
prompt_position = "top",
},
borderchars = border,
}
return {
defaults = {
path_display = { truncate = 1 },
prompt_prefix = " ",
selection_caret = icons.current .. " ",
multi_icon = icons.selected .. " ",
file_ignore_patterns = {
".git" .. path_delim,
"node_modules" .. path_delim,
},
mappings = {
i = {
["<esc>"] = actions.close,
},
},
borderchars = border
},
pickers = {
find_files = {
hidden = true,
},
buffers = vim.tbl_deep_extend("force", dropdown_opts, {
theme = "dropdown",
mappings = {
i = {
["<c-d>"] = actions.delete_buffer + actions.move_to_top,
},
},
}),
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown(dropdown_opts),
},
},
}
end

View file

@ -1,60 +0,0 @@
return {
-- A list of parser names
ensure_installed = {
"bash",
"c",
"cpp",
"ninja",
"cmake",
"dockerfile",
"make",
"lua",
"vim",
"vimdoc",
"query",
"php",
"phpdoc",
"blade",
"go",
"gotmpl",
"gomod",
"gosum",
"javascript",
"typescript",
"css",
"scss",
"html",
"vue",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"glsl",
"hlsl",
"markdown",
"markdown_inline",
"kdl",
},
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = true,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = false,
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
}

View file

@ -1,210 +0,0 @@
local keys = require("config.keymaps")
return {
-- colorscheme
{
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
config = function()
require("catppuccin").setup(require("config.colorscheme"))
vim.cmd.colorscheme("catppuccin")
end,
},
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = function()
return {
spec = keys.whichkey,
}
end,
config = function(_, opts)
local wk = require("which-key")
wk.setup(opts)
end,
},
{
"echasnovski/mini.bufremove",
},
{
"nvim-treesitter/nvim-treesitter",
build = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
"nvim-treesitter/playground",
},
opts = require("config.treesitter"),
config = function(_, opts)
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.blade = {
install_info = {
url = "https://github.com/EmranMR/tree-sitter-blade",
branch = "main",
files = { "src/parser.c" },
generate_requires_npm = true,
requires_generate_from_grammar = true,
},
filetype = "blade",
}
require("nvim-treesitter.configs").setup(opts)
end,
},
{
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true,
},
{
"windwp/nvim-ts-autotag",
dependencies = {
"nvim-treesitter/nvim-treesitter",
},
opts = require("config.autotag"),
},
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {
debounce = 10,
indent = {
char = "",
},
scope = {
enabled = true,
show_start = false,
show_end = false,
},
exclude = {
filetypes = {
"help",
"dashboard",
},
},
},
config = function(_, opts)
require("ibl").setup(opts)
local hooks = require("ibl.hooks")
hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_tab_indent_level)
hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level)
end,
},
{
"echasnovski/mini.nvim",
version = false,
},
-- Git stuff
{
"tpope/vim-fugitive",
keys = keys.fugitive,
},
{
"lewis6991/gitsigns.nvim",
dependencies = {
{
"folke/which-key.nvim",
optional = true,
opts = {
defaults = {
["<leader>g"] = { name = "+git" },
},
},
},
},
lazy = false,
keys = keys.gitsigns or {},
opts = require("config.gitsigns"),
},
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
dependencies = {
"arkav/lualine-lsp-progress",
"nvim-tree/nvim-web-devicons",
},
opts = require("config.lualine"),
},
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"sharkdp/fd",
"nvim-telescope/telescope-ui-select.nvim",
},
keys = keys.telescope,
opts = require("config.telescope"),
config = function(_, opts)
local telescope = require("telescope")
telescope.setup(opts)
for name, _ in pairs(opts.extensions or {}) do
telescope.load_extension(name)
end
end,
},
{
"stevearc/conform.nvim",
keys = keys.conform or {},
opts = require("config.conform"),
config = function(_, opts)
vim.api.nvim_create_user_command("Format", function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
---@diagnostic disable-next-line: undefined-field
["end"] = { args.line2, end_line:len() },
}
end
require("conform").format({ async = true, lsp_fallback = true, range = range })
end, { range = true })
require("conform").setup(opts)
end,
},
{
"stevearc/oil.nvim",
keys = keys.oil or {},
opts = require("config.oil"),
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function(_, opts)
require("oil").setup(opts)
-- Don't touch my CWD!
require("utils.oil").RegisterCWDHackHook()
end,
},
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
keys = keys.trouble or {},
opts = {},
},
{
"L3MON4D3/LuaSnip",
dependencies = {
{
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
},
},
opts = {},
config = function(_, opts)
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
require("luasnip").setup(opts)
end,
},
}

View file

@ -1,78 +0,0 @@
return {
"VonHeikemen/lsp-zero.nvim",
branch = "v3.x",
dependencies = {
"neovim/nvim-lspconfig",
"hrsh7th/cmp-nvim-lsp",
{
"nvimtools/none-ls.nvim",
opts = require("config.lsp").nonels,
config = function(_, opts)
require("null-ls").setup({sources = opts})
end,
},
-- completion
{
"hrsh7th/nvim-cmp",
version = false,
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-buffer", -- autocomplete from buffer
"hrsh7th/cmp-path", -- autocomplete from filesystem
"hrsh7th/cmp-nvim-lsp", -- autocomplete from lsp
"saadparwaiz1/cmp_luasnip", -- autocomplete from snippet engine
"L3MON4D3/LuaSnip", -- snippet engine
"onsails/lspkind-nvim", -- icons for kind
},
opts = require("config.cmp"),
config = function(_, opts)
local cmp = require("cmp")
cmp.setup(opts)
-- insert () on function completion using autopairs
cmp.event:on("confirm_done", require("nvim-autopairs.completion.cmp").on_confirm_done())
end,
},
},
opts = require("config.lsp"),
config = function(_, opts)
local lsp_zero = require("lsp-zero")
local lsp_config = require("lspconfig")
local augroup = vim.api.nvim_create_augroup("Lsp", {})
local utils = require("utils.lsp")
local map = require("utils.keys")
lsp_zero.on_attach(function(_, bufnr)
for _, v in ipairs(require("config.keymaps").lsp or {}) do
map(v, { buffer = bufnr })
end
end)
for name, server_opt in pairs(opts.servers) do
local on_attach = function(client, bufnr)
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
if server_opt.on_save then
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = server_opt.on_save,
})
end
-- if client.supports_method('textDocument/hover') then
-- utils.signature_help_on_hover(bufnr)
-- end
if (opts.document_hightlight or server_opt.document_highlight or false) and client.supports_method('textDocument/documentHighlight') then
utils.document_highlight(bufnr)
end
end
server_opt = vim.tbl_deep_extend("force", { on_attach = on_attach }, server_opt or {})
lsp_config[name].setup(server_opt)
end
end,
}

View file

@ -1,11 +0,0 @@
local M = {}
M.keymaps = function(opts)
opts = type(opts) == 'string' and require(opts) or opts
vim.g.mapleader = opts.leader
for _, v in ipairs(opts.global) do
vim.keymap.set(unpack(v))
end
end
return M

View file

@ -0,0 +1,19 @@
---@class EditorYankOptions
---@field enable boolean
---@field higroup string
---@field timeout number
---@class EditorOptions
---@field highlight_yank EditorYankOptions
---@class ExtendedOptions
---@field editor EditorOptions
return {
editor = {
highlight_yank = {
enable = true,
timeout = 400,
higroup = "IncSearch"
}
}
}

View file

@ -0,0 +1,3 @@
-- Load options and keymaps
require('config.options')
require('config.keymaps')

5
nvim/lua/user/extras.lua Normal file
View file

@ -0,0 +1,5 @@
-- Highlight on yank
if user.highlight_yank.enable or false then
require('user.utils.misc').highlight_yank(user.highlight_yank)
end

115
nvim/lua/user/icons.lua Normal file
View file

@ -0,0 +1,115 @@
return {
prompt = "",
current = " ",
selected = "",
close = "󰅖",
modified = "",
pinned = "",
separator = "",
edit = "",
buffer = "",
fold = {
open = "",
close = "",
sep = " ",
},
tree = {
node = "",
nodelast = "",
},
files = {
default = "",
text = "",
symlink = "",
},
file_status = {
modified = "",
readonly = "",
hidden = "󰛑",
},
folder = {
closed = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
},
diff = {
added = "",
modified = "",
removed = "",
},
diff_gutter = {
add = "",
change = "",
delete = "",
untracked = "+",
},
gitsigns = {
-- Change type
added = "",
modified = "",
deleted = "",
renamed = "",
-- Status type
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
todo = {
default = "",
warn = "",
perf = "",
bug = "",
hack = "",
test = "󰄉",
},
diagnostics = {
error = "",
warn = "",
info = "",
hint = "",
},
test = {
ok = "",
failed = "",
running = "",
skipped = "",
watch = "",
unknown = "",
},
symbols = {
Text = "󱀍",
Method = "",
Function = "󰊕",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "󰑭",
Value = "",
Number = "",
NumberHex = "󱊧",
Enum = "",
Keyword = "",
Snippet = "󰘦",
Color = "",
File = "󰈙",
Reference = "󰈇",
Folder = "󰉋",
EnumMember = "",
Constant = "",
Struct = "󰙅",
Event = "",
Operator = "󰆕",
TypeParameter = "",
Spell = "",
},
}

119
nvim/lua/user/keymaps.lua Normal file
View file

@ -0,0 +1,119 @@
local buffers = require('user.utils.buffers')
local telescope = require('user.utils.telescope')
vim.g.mapleader = ' '
-- NOPE
vim.keymap.set('n', 'Q', '<nop>')
--
-- Editing
--
vim.keymap.set("n", "<leader>W", "<cmd>lua vim.opt.list = not vim.opt.list._value<cr>", { silent = true, desc = "Toggle show whitespace" })
vim.keymap.set({'n', 'i'}, '<C-s>', vim.cmd.w, { desc = 'Save current buffer' })
-- Indent
vim.keymap.set('n', '<Tab>', '^=$')
vim.keymap.set('x', '<Tab>', '=', { desc = 'auto indent selection' })
vim.keymap.set('i', '<S-Tab', '<C-d>', { desc = 'delete indent' })
--
-- Editing - formatting
--
vim.keymap.set('n', '<leader>fs', [[:%s/\s\+$//g<CR>`']], { desc = 'Remove trailing spaces' })
-- Hex Formatting
vim.keymap.set('x', '<leader>fhx', [[:s/\(\x\{2\}\)/0x\1, /g]], { desc = "Format hex" })
vim.keymap.set('x', '<leader>fha', [[:s/0x\(\x\{1\}\X\)/0x0\1/g]], { desc = "Format hex" })
vim.keymap.set('x', '<leader>fhn', [[:s/\(\(0x\x\{1,2\}, \)\{8\}\)/\1\r/g]], { desc = "Format hex" })
-- Case formatting
vim.keymap.set("x", "<leader>fcsc", [[:s/\%V\([a-z]\+\)_\?/\u\1/g]], { desc = "Convert text from snake_case to CamelCase" })
-- copy/paste
vim.keymap.set({'n', 'v'}, '<leader>y', [["+y]], {})
vim.keymap.set({'n', 'v'}, '<leader>p', [["+p]], {})
vim.keymap.set('x', '<leader>p', [["_dP]], {silent = true })
--
-- Navigation
--
-- Move text
vim.keymap.set('n', '<S-a>', [[:m -2<CR>v=]], { silent = true, desc = 'move current line one line up' })
vim.keymap.set('n', '<S-d>', [[:m +1<CR>v=]], { silent = true, desc = 'move current line one line down' })
vim.keymap.set('v', '<S-a>', [[:m '<-2<CR>gv=gv]], { silent = true, desc = 'move current selection one line up' })
vim.keymap.set('v', '<S-d>', [[:m '>+1<CR>gv=gv]], { silent = true, desc = 'move current selection one line down' })
-- Make half page jumps stay in the center of screen
vim.keymap.set('n', '<C-u>', '<C-u>zz', { silent = true, desc = 'jump half a page up'})
vim.keymap.set('n', '<C-d>', '<C-d>zz', { silent = true, desc = 'jump half a page down'})
vim.keymap.set('n', '<S-PageUp>', '<C-u>zz', { silent = true, desc = 'jump half a page up'})
vim.keymap.set('n', '<S-PageDown>', '<C-d>zz', { silent = true, desc = 'jump half a page down'})
--
-- Buffers
--
-- vim.keymap.set('n', '<leader>bn', vim.cmd.bn, { silent = true, desc = 'Move to next buffer' })
-- vim.keymap.set('n', '<leader>bb', vim.cmd.bp, { silent = true, desc = 'Move to previous buffer' })
-- vim.keymap.set('n', '<leader>bd', vim.cmd.bd, { silent = true, desc = 'Close current buffer' })
-- vim.keymap.set('n', '<leader>bd', '<cmd>bp | bd #<cr>', { silent = true, desc = 'Close current buffer' })
vim.keymap.set('n', '<leader>bd', buffers.CloseCurrent, { silent = true, desc = 'Close current buffer' })
vim.keymap.set('n', '<leader>bc', buffers.CloseOthers, { silent = true, desc = 'Close all other buffers' })
vim.keymap.set('n', '<leader>bD', buffers.CloseAll, { silent = true, desc = 'Close all buffers' })
--
-- Diagnostics
--:bp | bd #
vim.keymap.set('n', "<leader>do", vim.diagnostic.open_float, {desc = "Open diagnostics" })
vim.keymap.set('n', "<leader>dn", vim.diagnostic.get_next, {desc = "Goto next" })
vim.keymap.set('n', "<leader>dp", vim.diagnostic.get_prev, {desc = "Goto previous" })
--
-- File explorer
--
vim.keymap.set('n', "<leader>.", "<cmd>Neotree toggle<cr>", {desc = "Toggle Neotree" })
--
-- Git
--
vim.keymap.set('n', "<leader>gp", "<cmd>Gitsigns preview_hunk<cr>", {desc = "Preview section at cursor" })
vim.keymap.set('n', "<leader>gr", "<cmd>Gitsigns reset_hunk<cr>", {desc = "Reset section at cursor" })
vim.keymap.set('n', "<leader>gR", "<cmd>Gitsigns reset_buffer<cr>", {desc = "Reset buffer" })
vim.keymap.set('n', "<leader>gv", "<cmd>Gitsigns select_hunk<cr>", {desc = "Select section under cursor" })
--
-- LSP
--
vim.keymap.set('n', 'go', '<cmd>Telescope lsp_type_definitions<cr>', {desc = 'Goto type definition' })
vim.keymap.set('n', 'gd', '<cmd>Telescope lsp_definitions<cr>', {desc = 'Goto definition' })
vim.keymap.set({'n', 'x'}, '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<cr>', {desc = 'Code action' })
vim.keymap.set('n', '<leader>rs', '<cmd>lua vim.lsp.buf.rename()<cr>', {desc = 'Rename symbol'} )
--
-- Search
--
vim.keymap.set('n', '<leader>sf', '<cmd>Telescope find_files<cr>', { desc = 'Search files' })
vim.keymap.set('n', '<leader>sF', telescope.all_files, { desc = 'Search all files' })
vim.keymap.set('n', '<leader>sw', '<cmd>Telescope grep_string<cr>', { desc = 'Search for word under cursor' })
vim.keymap.set('n', '<leader>sa', '<cmd>Telescope live_grep<cr>', { desc = 'Search in files' })
vim.keymap.set('n', '<leader>sb', '<cmd>Telescope buffers<cr>', { desc = 'Search Buffers' })
vim.keymap.set('n', '<leader>sg', '<cmd>Telescope git_files<cr>', { desc = 'Search Git files' })
vim.keymap.set('n', '<leader>sG', '<cmd>Telescope git_status<cr>', { desc = 'Search Git status' })
vim.keymap.set('n', '<leader>sc', '<cmd>Telescope git_commits<cr>', { desc = 'Search Git commits' })
vim.keymap.set('n', '<leader>so', '<cmd>Telescope oldfiles<cr>', { desc = 'Search old files' })
vim.keymap.set('n', '<leader>sd', '<cmd>Telescope diagnostics<cr>', { desc = 'Search Diagnostics' })
vim.keymap.set('n', '<leader>sq', '<cmd>Telescope quickfix<cr>', { desc = 'Search Quickfix' })
vim.keymap.set('n', '<leader>sr', '<cmd>Telescope lsp_references<cr>', { desc = 'Search Reference' })
vim.keymap.set('n', '<leader>ss', '<cmd>Telescope lsp_document_symbols<cr>', { desc = 'Search document symbols' })
vim.keymap.set('n', '<leader>si', '<cmd>Telescope lsp_implementations<cr>', { desc = 'Search Inplementations' })
vim.keymap.set('n', '<leader>sp', '<cmd>Telescope lsp_workspace_symbols<cr>', { desc = 'Search Workspace symbols' })
vim.keymap.set('n', '<leader>sh', '<cmd>Telescope help<cr>', { desc = 'Search Neovim help' })

66
nvim/lua/user/lazy.lua Normal file
View file

@ -0,0 +1,66 @@
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
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
spec = {
{ import = "user.plugins.core" },
{ import = "user.plugins.ui" },
{ import = "user.plugins.editor" },
{ import = "user.plugins.lsp" },
-- Language specific
{ import = "user.plugins.lang.lua" },
{ import = "user.plugins.lang.bash" },
{ import = "user.plugins.lang.clangd" },
{ import = "user.plugins.lang.go" },
{ import = "user.plugins.lang.rust" },
{ import = "user.plugins.lang.php" },
{ import = "user.plugins.lang.css" },
{ import = "user.plugins.lang.typescript" },
{ import = "user.plugins.lang.vue" },
},
pkg = {
sources = {
"lazy",
-- "rockspec",
-- "packspec",
},
},
dev = {
path = "~/code/nvim_plugins",
},
checker = {
enabled = false
},
change_detection = {
enabled = false,
notify = false
},
performance = {
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
}
}
})

114
nvim/lua/user/options.lua Normal file
View file

@ -0,0 +1,114 @@
-------------------------------------------------------
-- Helper imports
-------------------------------------------------------
local icons = require("user.icons")
-------------------------------------------------------
-- General options
-------------------------------------------------------
-- Decrease update time
vim.o.updatetime = 50
-- Decrease mapped sequence wait time
-- Displays which-key popup sooner
vim.o.timeoutlen = 50
vim.o.mouse="a"
vim.o.confirm = true
-------------------------------------------------------
-- User interface
-------------------------------------------------------
vim.o.winblend = 5 -- how much floating windows should blend with background.
vim.o.pumblend = 5 -- popup blend
vim.o.pumheight = 15 -- popup height
-- Configure how new splits should be opened
vim.o.splitbelow = true
vim.o.splitright = true
vim.o.shortmess = "atIF"
-------------------------------------------------------
-- Editor
-------------------------------------------------------
vim.o.wrap = false -- Disable line wrap
vim.o.cursorline = true
vim.o.scrolloff = 10
-- indent
vim.o.expandtab = true
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.shiftwidth = 4
vim.o.autoindent = true
vim.o.smartindent = true
-- line numbers
vim.o.number = true
vim.o.relativenumber = true
vim.o.numberwidth = 5
-- Gutter format
vim.o.statuscolumn = '%s %=%{v:relnum?v:relnum:v:lnum} │ '
-- search
vim.o.hlsearch = false
vim.o.incsearch = true
vim.o.ignorecase = true
vim.o.smartcase = true
-- Folds
vim.o.foldenable = true
vim.o.foldlevel = 99
vim.o.foldmethod = "expr"
vim.o.foldexpr = "nvim_treesitter#foldexpr()"
vim.o.foldcolumn = "auto"
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
vim.o.list = false
vim.o.listchars = 'tab: »,space:·,eol:,nbsp:␣'
-- Spell stuff, because i cant English
vim.o.spell = true
vim.o.spelllang = 'en_us'
vim.diagnostic.config({
virtual_text = false,
severity_sort = true,
underline = false,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = icons.diagnostics.error,
[vim.diagnostic.severity.WARN] = icons.diagnostics.warn,
[vim.diagnostic.severity.INFO] = icons.diagnostics.info,
[vim.diagnostic.severity.HINT] = icons.diagnostics.hint
},
},
float = {
border = { " " },
header = false,
source = true,
}
})
-------------------------------------------------------
-- Extras
-------------------------------------------------------
user = {}
user.highlight_yank = {
enable = true,
timeout = 400,
higroup = "IncSearch"
}

View file

@ -0,0 +1,163 @@
local options = {
flavour = "mocha",
transparent_background = true,
color_overrides = {
mocha = {
base = "#0E1019",
mantle = "#0D0F17",
crust = "#0C0D14",
surface0 = "#1a1c2d",
surface1 = "#343959",
surface2 = "#41476F",
overlay0 = "#3F4256",
overlay1 = "#5B5F7C",
overlay2 = "#767BA0",
text = "#eceef4",
},
},
no_italic = true,
no_bold = true,
highlight_overrides = {
mocha = function(colors)
return {
Visual = { bg = colors.overlay1 },
-- Floating windows
NormalFloat = { fg = colors.text, bg = colors.crust },
FloatTitle = { fg = colors.base, bg = colors.blue },
FloatBorder = { fg = colors.surface1, bg = colors.crust },
-- Window separator
WinSeparator = { fg = colors.surface0 },
-- Menus
Pmenu = { link = "NormalFloat" },
PmenuSel = { bg = colors.surface1 },
PmenuSbar = { link = "Pmenu" },
PmenuThumb = { link = "PmenuSel" },
-- NoiceMini = { link = "NormalFloat" },
WhichKeyFloat = { link = "Pmenu" },
-- indent lines
IblScope = { fg = colors.surface0 },
-- Search matches
IncSearch = { bg = colors.yellow },
-- Autocomplete window
CmpItemAbbr = { fg = colors.overlay2 },
CmpItemKindText = { fg = colors.text },
-- telescope
TelescopeNormal = { link = "NormalFloat" },
TelescopeBorder = { link = "FloatBorder" },
TelescopeTitle = { link = "FloatTitle" },
TelescopePromptNormal = { bg = colors.mantle },
TelescopePromptPrefix = { fg = colors.mauve },
TelescopePromptBorder = { fg = colors.mantle, bg = colors.mantle },
TelescopePreviewTitle = { fg = colors.crust, bg = colors.mauve },
TelescopeResultsNormal = { fg = colors.overlay2, bg = colors.crust },
TelescopeMatching = { link = "CmpItemAbbrMatch" },
TelescopeSelection = { link = "PmenuSel" },
TelescopeIndicatorModified = { fg = colors.yellow },
TelescopeIndicatorReadonly = { fg = colors.red },
TelescopeIndicatorHidden = { link = "TelescopeResultsComment" },
-- Statusline
StatusLine = { fg = colors.text, bg = colors.crust },
StatusLineNormal = { link = "StatusLine" },
StatusLineSeparator = { fg = colors.rosewater, bg = colors.crust },
StatusLineInsert = { fg = colors.base, bg = colors.blue },
StatusLineVisual = { fg = colors.base, bg = colors.mauve },
StatusLineCommand = { fg = colors.base, bg = colors.yellow },
StatusLineReplace = { fg = colors.base, bg = colors.maroon },
-- Neotree
NeoTreeTabActive = { bg = colors.surface2, fg = colors.lavender },
NeoTreeTabInactive = { bg = colors.crust, fg = colors.surface2 },
NeoTreeTabSeparatorActive = { fg = colors.base, bg = colors.surface2 },
NeoTreeTabSeparatorInactive = { fg = colors.base, bg = colors.crust },
NeoTreeFileIcon = { link = "Normal" },
NeoTreeModified = { fg = colors.yellow },
NeoTreeWinSeparator = { link = "WinSeparator" },
-- Syntax
PreProc = { link = "Include" },
Operator = { fg = colors.rosewater },
Function = { link = "@text" },
Delimiter = { link = "@text" },
Include = { fg = colors.mauve },
Keyword = { fg = colors.yellow },
Repeat = { link = "Keyword" },
Conditional = { link = "Keyword" },
Type = { fg = colors.blue },
String = { fg = colors.lavender },
Exception = { link = "Keyword" },
-- Treesitter tokens
["@constructor"] = { link = "Function" },
["@variable"] = { fg = colors.green },
["@variable.builtin"] = { link = "@variable" },
["@variable.parameter"] = { link = "@parameter" },
["@variable.member"] = { link = "@variable" },
["@parameter"] = { link = "@variable" },
["@keyword.function"] = { link = "Keyword" },
["@keyword.return"] = { link = "Keyword" },
["@keyword.operator"] = { link = "Keyword" },
["@property"] = { link = "@variable" },
["@tag"] = { link = "Keyword" },
["@tag.delimiter"] = { link = "@text" },
["@punctuation"] = { link = "@text" },
["@module"] = { link = "@text" },
["@punctuation.bracket"] = { link = "@punctuation" },
-- LSP
["@lsp.type.property"] = { link = "@variable" },
-- Bash
["@variable.parameter.bash"] = { fg=colors.rosewater },
-- Makefile
["@function.make"] = { link = "Keyword" },
["@string.special.symbol.make"] = { link = "@variable" },
-- Markup
["@markup.raw"] = { link = "@text" },
["@markup.strong"] = { fg = colors.blue },
["@markup.italic"] = { fg = colors.green },
-- PHP
["@keyword.import.php"] = { link = "@keyword" },
["@class_name.php"] = { link = "@text" },
["@extend_name.php"] = { link = "@text" },
["@implement_name.php"] = { link = "@text" },
["@namespace_name.php"] = { link = "@text" },
["@namespace_alias.php"] = { link = "@text" },
}
end,
},
integrations = {
cmp = true,
treesitter = true,
neotree = true,
-- barbar = true,
-- noice = true,
telescope = {
enabled = true,
},
}
}
return {
"catppuccin/nvim",
name = "catppuccin",
lazy = false,
priority = 1000,
opts = options,
config = function(_, opts)
require("catppuccin").setup(opts)
vim.cmd.colorscheme("catppuccin")
end,
}

View file

@ -0,0 +1,65 @@
return {
"echasnovski/mini.bufremove",
{
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true,
},
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {
debounce = 10,
indent = {
char = "",
},
scope = {
enabled = false,
},
exclude = {
filetypes = {
"help",
"dashboard",
},
},
},
config = function(_, opts)
require("ibl").setup(opts)
local hooks = require("ibl.hooks")
hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_tab_indent_level)
hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level)
end,
},
-- Snippets
{
"L3MON4D3/LuaSnip",
dependencies = {
{
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
},
{
"hrsh7th/nvim-cmp",
optional = true,
dependencies = {
"saadparwaiz1/cmp_luasnip"
},
opts = {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
}
}
}
},
opts = {},
config = function(_, opts)
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
require("luasnip").setup(opts)
end,
},
}

View file

@ -0,0 +1,93 @@
return {
"hrsh7th/nvim-cmp",
version = false,
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-buffer", -- autocomplete from buffer
"hrsh7th/cmp-path", -- autocomplete from filesystem
"f3fora/cmp-spell",
},
opts = function()
local cmp = require("cmp")
local utils = require("user.utils.cmp")
local format = require("user.utils.cmp_format")
-- local lspkind = require("user.utils.lspkind")
local icons = require("user.icons")
local selectPrev = utils.selectPrev({ behavior = cmp.SelectBehavior.Insert })
local selectNext = utils.selectNext({ behavior = cmp.SelectBehavior.Insert })
return {
preselect = false,
completion = {
completeopt = "menu,menuone,longest,popup",
},
view = {
entries = { name = "custom", selection_order = "near_cursor" },
},
window = {
documentation = {
border = { "", "", "", "", "", "", "", " " },
},
completion = {
scrolloff = 4,
},
},
mapping = {
["<Up>"] = selectPrev,
["<S-Tab>"] = selectPrev,
["<Down>"] = selectNext,
["<Tab>"] = selectNext,
["<C-c>"] = cmp.mapping.abort(),
["<CR>"] = utils.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
},
-- snippet = {
-- expand = function(args)
-- require("luasnip").lsp_expand(args.body)
-- end,
-- },
formatting = {
fields = { "abbr", "kind", "menu" },
format = format({
symbol_map = icons.symbols,
widths = {
menu = 0,
}
}),
},
sources = {
{ name = "nvim_lsp" },
{ name = 'nvim_lsp_signature_help' },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
{
name = "spell",
keyword_length = 3,
option = {
keep_all_entries = false,
enable_in_context = function()
return true
end,
preselect_correct_word = true,
},
},
},
-- experimental = {
-- ghost_text = {
-- hl_group = "NonText",
-- },
-- },
}
end,
config = function(_, opts)
local cmp = require("cmp")
cmp.setup(opts)
-- insert () on function completion using autopairs
local has_autopair, autopair = pcall(require, "nvim-autopairs.completion.cmp")
if has_autopair then
cmp.event:on("confirm_done", autopair.on_confirm_done())
end
end,
}

View file

@ -0,0 +1,90 @@
local icons = require("user.icons")
local path_delim = require("user.utils.path").delimiter()
local border = {
prompt = { " " },
results = { " " },
preview = { " " },
}
local dropdown_opts = {
previewer = false,
prompt_title = false,
layout_strategy = "horizontal",
layout_config = {
prompt_position = "top",
},
borderchars = border,
}
return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"nvim-telescope/telescope-ui-select.nvim",
"sharkdp/fd",
},
opts = function()
local utils = require("user.utils.telescope")
local actions = require("telescope.actions")
return {
defaults = {
path_display = { truncate = 1 },
prompt_prefix = " ",
selection_caret = icons.current .. " ",
multi_icon = icons.selected .. " ",
file_ignore_patterns = {
".git" .. path_delim,
"node_modules" .. path_delim,
},
mappings = {
i = {
["<esc>"] = actions.close,
},
},
borderchars = border,
},
pickers = {
find_files = {
hidden = true,
},
buffers = vim.tbl_deep_extend("force", dropdown_opts, {
theme = "dropdown",
mappings = {
i = {
["<c-d>"] = actions.delete_buffer + actions.move_to_top,
},
},
sort_mru = true, -- sort by most recent used.
entry_maker = utils.buffer_view({
indicators = {
modified = {
icon = icons.file_status.modified,
},
readonly = {
icon = icons.file_status.readonly,
},
hidden = {
icon = icons.file_status.hidden,
}
}
})
}),
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown(dropdown_opts),
},
}
}
end,
config = function(_, opts)
local telescope = require("telescope")
telescope.setup(opts)
for name, _ in pairs(opts.extensions or {}) do
telescope.load_extension(name)
end
end,
}

View file

@ -0,0 +1,37 @@
local icons = require('user.icons').diff_gutter
return {
"lewis6991/gitsigns.nvim",
dependencies = {
{
"folke/which-key.nvim",
optional = true,
opts = {
defaults = {
["<leader>g"] = { name = "+git" },
},
},
},
},
lazy = false,
opts = {
signs = {
add = { text = icons.add },
delete = { text = icons.delete },
change = { text = icons.change },
untracked = { text = icons.untracked },
topdelete = { text = icons.delete },
changedelete = { text = icons.change },
},
signs_staged = {
add = { text = icons.add },
delete = { text = icons.delete },
change = { text = icons.change },
topdelete = { text = icons.delete },
changedelete = { text = icons.change },
},
diff_opts = {
internal = true
}
},
}

View file

@ -0,0 +1,89 @@
return {
"nvim-treesitter/nvim-treesitter",
build = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
dependencies = {
-- "nvim-treesitter/nvim-treesitter-textobjects",
{
"windwp/nvim-ts-autotag",
opts = {
-- Filetypes to enable autotag for
filetypes = {
'html',
'javascript',
'typescript',
'javascriptreact',
'typescriptreact',
'svelte',
'vue',
'tsx',
'jsx',
'rescript',
'xml',
'php',
'blade',
'markdown',
},
},
},
},
opts = {
-- A list of parser names
ensure_installed = {
"bash",
"c",
"cpp",
"ninja",
"cmake",
"dockerfile",
"make",
"vim",
"vimdoc",
"query",
"javascript",
-- "typescript",
"css",
"scss",
-- "html",
-- "vue",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"glsl",
"hlsl",
"markdown",
"markdown_inline",
"kdl",
},
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
},
config = function(_, opts)
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.blade = {
install_info = {
url = "https://github.com/EmranMR/tree-sitter-blade",
branch = "main",
files = { "src/parser.c" },
generate_requires_npm = true,
requires_generate_from_grammar = true,
},
filetype = "blade",
}
require("nvim-treesitter.configs").setup(opts)
end,
}

View file

@ -0,0 +1,16 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "bash" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
bashls = {}
}
},
}
}

View file

@ -0,0 +1,8 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "blade" }
}
},
}

View file

@ -0,0 +1,16 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "c", "cpp" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
clangd = {}
}
},
}
}

View file

@ -0,0 +1,16 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "css", "scss" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
tailwindcss = {},
}
},
}
}

View file

@ -0,0 +1,43 @@
local lspservers = {
gopls = {
settings = {
gopls = {
analyses = {
unusedvariable = true,
unusedwrite = true,
useany = true,
},
gofumpt = true,
},
},
on_save = function()
local params = vim.lsp.util.make_range_params()
params.context = { only = { "source.organizeImports" } }
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000)
for cid, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
vim.lsp.util.apply_workspace_edit(r.edit, enc)
end
end
end
vim.lsp.buf.format({ async = false })
end,
},
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "go", "gomod", "gowork", "gosum" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = lspservers
},
}
}

View file

@ -0,0 +1,8 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "html" }
}
}
}

View file

@ -0,0 +1,33 @@
local lspservers = {
lua_ls = {
cmd = { "/opt/luals/bin/lua-language-server", "--logpath=~/.local/luals/logs" },
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
},
},
},
},
},
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "lua" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = lspservers
}
}
}

View file

@ -0,0 +1,25 @@
local lspservers = {
phpactor = {
settings = {
init_options = {
["language_server_phpstan.enabled"] = true,
["language_server_psalm.enabled"] = false,
},
},
},
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "php", "phpdoc" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = lspservers
},
}
}

View file

@ -0,0 +1,37 @@
local lspservers = {
rust_analyzer = {
-- settings = {
-- ["rust-analyzer"] = {
-- imports = {
-- granularity = {
-- group = "module",
-- },
-- prefix = "self",
-- },
-- cargo = {
-- buildScripts = {
-- enable = true,
-- },
-- },
-- procMacro = {
-- enable = true
-- },
-- }
-- }
}
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "rust", "toml" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = lspservers
},
}
}

View file

@ -0,0 +1,24 @@
local lspservers = {
tsserver = {
settings = {
-- tsserver_plugins = {
-- "@vue/typescript-plugin",
-- },
},
},
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "typescript" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = lspservers
},
}
}

View file

@ -0,0 +1,36 @@
local lspservers = {
volar = {
init_options = {
vue = {
hybridMode = true,
},
},
},
tsserver = {
settings = {
tsserver_plugins = {
"@vue/typescript-plugin",
},
},
},
}
return {
-- Vue needs typescript
{ import = "user.plugins.lang.typescript" },
-- And most likely css/scss aswell.
{ import = "user.plugins.lang.css" },
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "vue" }
}
},
{
"neovim/nvim-lspconfig",
opts = {
servers = lspservers
},
}
}

View file

@ -0,0 +1,53 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
{
-- Autocomplete source
"hrsh7th/nvim-cmp",
optional = true,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lsp-signature-help"
},
},
},
opts = {
document_highlight = {
enabled = true,
},
codelens = {
enabled = false,
},
inlay_hints = {
enabled = false,
exclude = {},
},
servers = {},
},
config = function(_, opts)
local lspconfig = require("lspconfig")
local augroup = vim.api.nvim_create_augroup("Lsp", {})
for name, server_opts in pairs(opts.servers) do
local on_attach = function(_, bufnr)
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
-- Setup on save handler
if server_opts.on_save then
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = server_opts.on_save,
})
end
end
server_opts = vim.tbl_deep_extend("force", {
on_attach = on_attach
}, server_opts or {})
lspconfig[name].setup(server_opts)
end
end,
}

View file

@ -0,0 +1,104 @@
local icons = require("user.icons")
return {
-- File explorer
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
},
opts = {
-- hide_root_node = true,
popup_border_style = 'solid',
default_component_configs = {
indent = {
with_markers = false,
indent_marker = icons.tree.node,
last_indent_marker = icons.tree.nodelast,
indent_size = 2,
},
icon = {
folder_closed = icons.folder.closed,
folder_open = icons.folder.open,
folder_empty = icons.folder.empty,
folder_empty_open = icons.folder.empty_open,
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = icons.files.default,
},
modified = {
symbol = icons.modified,
},
name = {
highlight_opened_files = true,
},
git_status = {
symbols = icons.gitsigns,
align = "right",
},
},
sources = {
"filesystem",
"buffers",
"git_status",
"document_symbols",
},
source_selector = {
winbar = true, -- toggle to show selector on winbar
show_scrolled_off_parent_node = false, -- boolean
sources = { -- table
{
source = "filesystem", -- string
display_name = " 󰉓 Files " -- string | nil
},
{
source = "buffers", -- string
display_name = " 󰈚 Buffers " -- string | nil
},
{
source = "git_status", -- string
display_name = " 󰊢 Git " -- string | nil
},
{
source = "document_symbols", -- string
display_name = " 󰊢 Docments " -- string | nil
},
},
content_layout = "center",
separator = { left = "", right= "", override = "active" },
-- show_separator_on_edge = true,
},
window = {
popup = {
size = {
height = "100%",
width = "100%",
},
position = "50%",
relative = "editor",
},
},
filesystem = {
follow_current_file = {
enabled = true,
},
use_libuv_file_watcher = true,
},
event_handlers = {
{
event = "neo_tree_buffer_enter",
handler = function ()
vim.opt_local.statuscolumn = ''
end
},
},
},
},
{
"folke/which-key.nvim",
event = "VeryLazy",
}
}

View file

@ -0,0 +1,133 @@
local icons = require("user.icons")
local function indent_settings()
return (vim.bo.expandtab and "SPC" or "TAB")
.. " "
.. (vim.bo.shiftwidth == 0 and vim.bo.tabstop or vim.bo.shiftwidth)
end
local function lsp_info()
local num_clients = tostring(#vim.tbl_keys(vim.lsp.buf_get_clients()))
return "" .. num_clients
end
return {
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
dependencies = {
"arkav/lualine-lsp-progress",
"nvim-tree/nvim-web-devicons",
},
opts = {
options = {
globalstatus = true,
component_separators = "",
-- section_separators = { "'" .. icons.separator .. "'", color = "StatusLineSeparator" },
section_separators = "",
disabled_filetypes = {
statusline = {
"dashboard",
},
winbar = {
"neo-tree",
}
},
theme = {
normal = {
a = "StatusLineNormal",
b = "StatusLine",
c = "StatusLine",
x = "StatusLine",
y = "StatusLine",
z = "StatusLine",
},
command = {
a = "StatusLineCommand",
z = "StatusLine",
},
insert = {
a = "StatusLineInsert",
z = "StatusLine",
},
visual = {
a = "StatusLineVisual",
z = "StatusLine",
},
replace = {
a = "StatusLineReplace",
z = "StatusLine",
},
},
},
sections = {
lualine_a = {
{
"mode",
separator = "|"
},
},
lualine_b = {
"branch",
-- '" " .. tostring(#vim.tbl_keys(vim.lsp.buf_get_clients()))',
lsp_info,
{
"diagnostics",
symbols = {
error = icons.diagnostics.error .. " ",
warn = icons.diagnostics.warn .. " ",
info = icons.diagnostics.info .. " ",
hint = icons.diagnostics.hint .. " ",
},
},
{
"diff",
symbols = {
added = icons.diff.added .. " ",
modified = icons.diff.modified .. " ",
removed = icons.diff.removed .. " ",
},
},
},
lualine_c = {
{
"filename",
path = 1,
symbols = vim.tbl_deep_extend("force", icons.file_status, {
unnamed = "",
})
},
},
lualine_x = {
"filetype",
"fileformat",
-- '(vim.bo.expandtab and "SPC" or "TAB") .. " " .. (vim.bo.shiftwidth == 0 and vim.bo.tabstop or vim.bo.shiftwidth)',
indent_settings,
},
lualine_y = {
"location",
"progress",
},
lualine_z = {},
},
winbar = {
lualine_c = {
{ "filetype", icon_only = true },
"filename",
},
},
inactive_winbar = {
lualine_c = {
{ "filetype", icon_only = true },
"filename",
},
},
extensions = {
"lazy",
"neo-tree",
},
},
init = function ()
-- disable mode in the command line, as its already shown in lualine
vim.o.showmode = false
end
}

View file

@ -18,20 +18,24 @@ function M.Close(buf)
else
bd(buf)
end
-- fallback to native nvim api
-- fallback to native nvim api
else
vim.api.nvim_buf_delete(buf, {})
end
end
-- Close current buffer
function M.CloseCurrent()
M.Close(vim.api.nvim_get_current_buf())
end
-- Close all but current buffer
function M.CloseOthers()
for _, i in ipairs(vim.api.nvim_list_bufs()) do
if i ~= vim.api.nvim_get_current_buf() then
M.Close(i)
end
end
for _, i in ipairs(vim.api.nvim_list_bufs()) do
if i ~= vim.api.nvim_get_current_buf() then
M.Close(i)
end
end
end
-- Close all open buffers

View file

@ -1,4 +1,4 @@
local luasnip = require("luasnip")
local hasluansp, luasnip = pcall(require, "luasnip")
local cmp = require("cmp")
local M = {}
@ -7,7 +7,7 @@ function M.selectNext(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item(opts or {})
elseif luasnip.locally_jumpable(1) then
elseif hasluansp and luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
@ -19,7 +19,7 @@ function M.selectPrev(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item(opts or {})
elseif luasnip.locally_jumpable(-1) then
elseif hasluansp and luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()

View file

@ -0,0 +1,72 @@
---@param text string
---@param width number
---@param ellipsis string
---@return string
local function format_fixed_length(text, width, ellipsis)
text = text or ""
if width < 1 then
return text
end
local len = vim.fn.strdisplaywidth(text)
if text and len > width then
text = vim.fn.strcharpart(text, 0, width - vim.fn.strdisplaywidth(ellipsis)) .. ellipsis
elseif width > 0 then
text = text .. string.rep(' ', width - len)
end
return text
end
---@param entry any
---@param kind any
---@param map any
---@return {icon: string, hl_group: string}|string
local function get_icon(entry, kind, map)
if vim.tbl_contains({ 'path' }, entry.source.name) then
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
if icon then
return {
icon = icon,
hl_group = hl_group
}
end
end
if entry.source.name == "snippet" then
return map["Snippet"] or "Snippet"
end
if entry.source.name == "spell" then
return map["Spell"] or "Spell"
end
return map[kind] or "?"
end
return function (opts)
return function(entry, item)
local icon = get_icon(entry, item.kind, opts.symbol_map)
if type(icon) == "table" then
item.kind = icon.icon
item.kind_hl_group = icon.hl_group
else
item.kind = icon
end
local widths = {
abbr = opts.widths and opts.widths.abbr or 20,
menu = opts.widths and opts.widths.menu or 15,
}
local ellipsis = opts.ellipsis or '...'
for key, width in pairs(widths) do
item[key] = format_fixed_length(item[key], width, ellipsis)
end
return item
end
end

View file

@ -0,0 +1,18 @@
local M = {}
function M.setHardtabs()
-- vim.bo.expandtab = false
-- vim.bo.tabstop = 8
-- vim.bo.shiftwidth = 0
-- vim.bo.softtabstop = 0
vim.cmd([[setlocal noet ts=8 sts=0 sw=0]])
end
---@param width number
function M.setSofttabs(width, isLocal)
isLocal = (isLocal or false) and "local" or ""
vim.cmd(string.format("set%s et ts=%s sts=0 sw=%s", isLocal, width, width))
end
return M

View file

@ -0,0 +1,15 @@
local M = {}
M.highlight_yank = function(opts)
vim.api.nvim_create_autocmd("TextYankPost", {
group = vim.api.nvim_create_augroup("highlight_yank", {}),
desc = "Hightlight selection on yank",
pattern = "*",
callback = function()
vim.highlight.on_yank(opts)
end,
})
end
return M

View file

@ -0,0 +1,99 @@
local M = {}
function M.all_files() require("telescope.builtin").find_files({no_ignore=true, prompt_title = "Find All Files"}) end
function M.buffer_view(opts)
local devicons = require("nvim-web-devicons")
local entry_display = require("telescope.pickers.entry_display")
local filter = vim.tbl_filter
local map = vim.tbl_map
local defaults = {
indicators = {
modified = {
icon = "+",
higroup = "TelescopeIndicatorModified",
},
readonly = {
icon = "=",
higroup = "TelescopeIndicatorReadonly",
},
hidden = {
icon = "h",
higroup = "TelescopeIndicatorHidden",
}
}
}
opts = vim.tbl_deep_extend('force', defaults, opts)
local default_icons, _ = devicons.get_icon("file", "", {default = true})
-- local bufnrs = filter(function(b)
-- return 1 == vim.fn.buflisted(b)
-- end, vim.api.nvim_list_bufs())
--
-- local max_bufnr = math.max(unpack(bufnrs))
-- local bufnr_width = #tostring(max_bufnr)
local displayer = entry_display.create {
separator = "",
items = {
-- { width = bufnr_width },
{ width = 2 },
{ width = 2 },
-- { width = 2 },
{ width = vim.fn.strwidth(default_icons) + 1 },
{ remaining = true },
},
}
local make_display = function(entry)
return displayer {
-- {entry.bufnr, "TelescopeResultsNumber"},
{entry.indicator.readonly.icon, entry.indicator.readonly.highlight},
{entry.indicator.changed.icon, entry.indicator.changed.highlight},
-- {entry.indicator.hidden.icon, entry.indicator.hidden.highlight},
{entry.file_icon, entry.file_highlight},
entry.file_name,
}
end
return function(entry)
local bufname = entry.info.name ~= "" and entry.info.name or "[No Name]"
local file_name = vim.fn.fnamemodify(bufname, ":.")
local file_icon, file_highlight = devicons.get_icon(bufname, string.match(bufname, "%a+$"), { default = true })
return {
valid = true,
value = bufname,
ordinal = entry.bufnr .. " : " .. bufname,
display = make_display,
bufnr = entry.bufnr,
lnum = entry.info.lnum ~= 0 and entry.info.lnum or 1,
indicator = {
-- hidden = {
-- icon = entry.info.hidden == 1 and opts.indicators.hidden.icon or " ",
-- highlight = opts.indicators.hidden.higroup
-- },
changed = {
icon = entry.info.changed == 1 and opts.indicators.modified.icon or " ",
highlight = opts.indicators.modified.higroup
},
readonly = {
icon = vim.api.nvim_buf_get_option(entry.bufnr, "readonly") and opts.indicators.readonly.icon or " ",
highlight = opts.indicators.readonly.higroup
}
},
file_icon = file_icon,
file_highlight = file_highlight,
file_name = file_name,
}
end
end
return M

View file

@ -1,13 +0,0 @@
return function(v, opts)
local c = vim.deepcopy(v)
local lhs = table.remove(c, 1)
local rhs = table.remove(c, 1)
opts = vim.tbl_deep_extend("force", c, opts or {})
local mode = 'n'
if opts.mode then
mode = opts.mode
opts.mode = nil
end
vim.keymap.set(mode, lhs, rhs, opts)
end

View file

@ -1,21 +0,0 @@
local M = {}
-- Create format function.
function M.format(config)
return function(entry, vim_item)
-- Devicons for files
if vim.tbl_contains({ 'path' }, entry.source.name) then
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
if icon then
vim_item.kind = icon
vim_item.kind_hl_group = hl_group
return vim_item
end
end
return require('lspkind').cmp_format(config)(entry, vim_item)
end
end
return M

View file

@ -1,17 +0,0 @@
local M = {}
-- Hack for making oil.nvim return to
-- the initial cwd on save.
function M.RegisterCWDHackHook()
local cwd = vim.fn.getcwd()
local group = vim.api.nvim_create_augroup("OilCWDHack", {})
vim.api.nvim_create_autocmd("BufWritePost", {
group = group,
pattern = "oil:///*",
callback = function() vim.cmd("cd " .. cwd) end,
})
end
return M

View file

@ -1,6 +0,0 @@
local M = {}
function M.all_files() require("telescope.builtin").find_files({no_ignore=true}) end
return M

View file

@ -1,7 +1,7 @@
; extends
; Fix for phpdoc comments that don't align * properly.
; This is black magic. I came up with it myself but
; This is black magic. I came up with it myself but
; i don't know why it works.
;(ERROR
; "/"

View file

@ -1,12 +0,0 @@
local ls = require('luasnip')
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
return {
s("ternary", {
i(1, "cond"), t(" ? "), i(2, "true"), t(" : "), i(3, "false")
})
}

View file

@ -1,21 +0,0 @@
local ls = require('luasnip')
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
return {
s("iferr", {
t({"if err != nil {", ""}),
t({"\treturn err", ""}),
t({"}"})
}),
-- Test function
s("tst", {
t("func Test"), i(1, "Module"), t("_"), i(2, "Name"), t({"(t *testing.T) {", ""}),
i(0),
t({"", "}"})
})
}

View file

@ -1,164 +0,0 @@
local q = require('vim.treesitter.query')
local ls = require('luasnip')
local s = ls.snippet
-- local sn = ls.snippet_node
-- local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
-- local d = ls.dynamic_node
-- local r = ls.restore_node
-- local events = require('luasnip.util.events')
-- local ai = require('luasnip.nodes.absolute_indexer')
local fmt = require('luasnip.extras.fmt').fmt
-- local m = require('luasnip.extras').m
-- local lambda = require('luasnip.extras').l
local rep = require('luasnip.extras').rep
-- local postfix = require('luasnip.extras.postfix').postfix
local visibility_modifiers = {
t('public'),
t('private'),
t('protected'),
}
local query_constructor_args = vim.treesitter.query.parse(
'php',
[[
(method_declaration
name: (name) @method_name (#eq? @method_name "__construct")
parameters:
(formal_parameters
(simple_parameter name: (variable_name (name) @arg_name ))
))
]]
)
return {
-- Class
s(
{
trig = 'cl',
},
fmt(
[[
/**
* {} {}
*
*/
{}
class {} {{
{}
{} function __construct({}) {{
{}
}}
}}
]],
{
i(1, 'Class description'),
i(2, 'Classname'),
---@diagnostic disable-next-line: unused-local
f(function(args, snip, user_arg)
-- TODO: generate namespace using parent directories
return 'namespace ' .. args[1][1] .. ';'
end, { 2 }),
rep(2),
---@diagnostic disable-next-line: unused-local
f(function(args, snip, user_arg)
local parser = vim.treesitter.get_parser(0, 'php')
local syntax_tree = parser:parse()
local root = syntax_tree[1]:root()
local text = ''
local fields = { '' }
for _, match, _ in query_constructor_args:iter_matches(root, 0) do
for id, node in pairs(match) do
local name = query_constructor_args.captures[id]
if name == 'arg_name' then
text = q.get_node_text(node, 0)
fields[#fields + 1] = 'private $_' .. text .. ';'
end
end
end
return fields
end, 4),
c(3, visibility_modifiers),
i(4, '/* Constructor parameters */'),
f(function()
local parser = vim.treesitter.get_parser(0, 'php')
local syntax_tree = parser:parse()
local root = syntax_tree[1]:root()
local text = ''
local fields = { '' }
for _, match, _ in query_constructor_args:iter_matches(root, 0) do
for id, node in pairs(match) do
local name = query_constructor_args.captures[id]
if name == 'arg_name' then
text = q.get_node_text(node, 0)
fields[#fields + 1] = '$this->_' .. text .. '= $' .. text .. ';'
end
end
end
return fields
end, { 4 }),
}
)
),
s(
{
trig = 'am',
},
fmt(
[[
Cacca
]],
{}
)
),
s(
{
trig = 'af',
},
fmt(
[[
Cacca
]],
{}
)
),
-- Getter Setter
s(
{
trig = 'getset'
},
fmt([[
public function get{}() : {} {{
return {};
}}
public function set{}(${} {}) {{
$this->{} = ${};
return $this;
}}
]], {
i(1, 'Name'),
i(2, 'Type'),
rep(1), -- getter return type
rep(1), -- getter return value
rep(1), -- setter arg name
rep(2), -- setter arg type
rep(2), -- setter property
rep(1), -- setter value
})
)
}, {}