1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-17 03:30:01 +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

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

@ -0,0 +1,58 @@
-- Helper functions for dealing with buffers
local M = {}
function M.Close(buf)
-- check if mini is installed.
local hasmini, mini = pcall(require,"mini.bufremove")
if hasmini then
local bd = mini.delete
if vim.bo[buf].modified then
local bufname = vim.fn.bufname(buf)
local choice = vim.fn.confirm(("Save changes to %q?"):format(bufname), "&Yes\n&No\n&Cancel")
if choice == 1 then -- Yes
vim.cmd(("%i,%ibufdo w"):format(buf, buf))
bd(buf)
elseif choice == 2 then -- No
bd(buf, true)
end
else
bd(buf)
end
-- 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
end
-- Close all open buffers
function M.CloseAll()
for _, i in ipairs(vim.api.nvim_list_bufs()) do
M.Close(i)
end
end
function M.GetLoaded()
local loaded = {}
for i, hnd in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_loaded(hnd) then
loaded[i] = hnd
end
end
return loaded
end
return M

View file

@ -0,0 +1,44 @@
local hasluansp, luasnip = pcall(require, "luasnip")
local cmp = require("cmp")
local M = {}
function M.selectNext(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item(opts or {})
elseif hasluansp and luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" })
end
function M.selectPrev(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item(opts or {})
elseif hasluansp and luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" })
end
function M.confirm(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
-- if luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- else
cmp.confirm(opts or {})
-- end
else
fallback()
end
end)
end
return M

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,32 @@
local M = {}
function M.document_highlight(bufnr)
local group = vim.api.nvim_create_augroup('lsp_document_highlight', { clear = false })
vim.api.nvim_clear_autocmds({
buffer = bufnr,
group = group,
})
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
group = group,
buffer = bufnr,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
group = group,
buffer = bufnr,
callback = vim.lsp.buf.clear_references,
})
end
function M.signature_help_on_hover(bufnr)
local group = vim.api.nvim_create_augroup('lsp_hover', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
group = group,
buffer = bufnr,
callback = vim.lsp.buf.hover,
})
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,11 @@
local M = {}
function M.delimiter()
if vim.fn.has('win32') then
return '\\'
end
return '/'
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