1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-17 19:40:02 +02:00

new nvim config

This commit is contained in:
Henrik Hautakoski 2024-05-06 16:07:18 +02:00
parent 4b730d3924
commit 7388c9bfd3
78 changed files with 1291 additions and 43 deletions

View file

@ -0,0 +1,46 @@
local icons = require('config.icons')
return function()
local highlightfunc = require("catppuccin.groups.integrations.bufferline")
return {
highlights = highlightfunc.get(),
options = {
mode = "buffers",
themable = true,
buffer_close_icon = icons.close,
close_icon = icons.close,
modified_icon = icons.modified,
diagnostics = false,
enforce_regular_tabs = true,
indicator = {
icon = "",
},
close_command = function(bufnum)
vim.cmd("bprev")
vim.api.nvim_buf_delete(bufnum, {})
end,
hover = {
enabled = true,
delay = 200,
reveal = { 'close' }
},
offsets = {
{
filetype = "neo-tree",
text = "File Explorer",
text_align = "left"
}
},
custom_areas = {
left = function()
return {
{
text = "",
fg = "#8fff6d",
}
}
end
}
}
}
end

View file

@ -0,0 +1,115 @@
return {
flavour = "mocha",
color_overrides = {
mocha = {
base = '#0E1019',
mantle = '#0D0F17',
crust = '#0C0D14',
surface0 = '#131521',
surface1 = '#343959',
surface2 = '#41476F',
overlay0 = '#3F4256',
overlay1 = '#5B5F7C',
overlay2 = '#767BA0',
text = '#eceef4',
}
},
no_italic = true,
no_bold = true,
highlight_overrides = {
mocha = function(colors)
return {
-- Normal = { fg = colors.text },
-- NormalNC = { fg = colors.text },
-- Floating windows
NormalFloat = { fg = colors.text, bg = colors.mantle },
FloatTitle = { fg = colors.base, bg = colors.blue },
FloatBorder = { fg = colors.blue, bg = colors.mantle },
-- Window separator
WinSeparator = { fg = colors.surface0 },
NeoTreeWinSeparator = { link = "WinSeparator" },
-- Menus
Pmenu = { fg = colors.text, bg = colors.mantle },
-- NoiceMini = { link = "NormalFloat" },
WhichKeyFloat = { link = "Pmenu" },
-- indent lines
IblScope = { fg = colors.overlay1 },
-- LSP
-- LspReferenceText = { bg = colors.surface0 },
-- LspReferenceRead = { link = "LspReferenceText" },
-- LspReferenceWrite = { link = "LspReferenceText" },
--
-- -- telescope
TelescopeNormal = { bg = colors.crust },
TelescopeBorder = { fg = colors.crust, bg = colors.crust },
TelescopePromptNormal = { bg = colors.mantle },
TelescopePromptPrefix = { fg = colors.mauve },
TelescopePromptBorder = { fg = colors.mantle, bg = colors.mantle },
TelescopePromptTitle = { fg = colors.crust, bg = colors.blue },
TelescopePreviewTitle = { fg = colors.crust, bg = colors.mauve },
TelescopeSelection = { fg = colors.text, bg = colors.surface0 },
-- Statusline
StatusLine = { fg = colors.text, bg = colors.mantle },
StatusLineNormal = { fg = colors.text, bg = colors.mantle },
StatusLineSeparator = { fg = colors.surface0, bg = colors.mantle },
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" },
-- PHP specific
["@class_name.php"] = { link = "@text" },
["@extend_name.php"] = { link = "@text" },
["@implements_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

@ -0,0 +1,59 @@
return function()
local cmp = require('cmp')
local lspkind = require('utils.lspkind')
local icons = require('config.icons')
local selectPrev = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
local selectNext = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert })
local borderstyle = {
border = "none",
winhighlight = 'Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None',
}
return {
preselect = false,
view = {
entries = { name = 'custom', selection_order = 'near_cursor' },
},
window = {
documentation = borderstyle,
completion = borderstyle
},
mapping = {
["<Up>"] = selectPrev,
["<S-Tab>"] = selectPrev,
["<Down>"] = selectNext,
["<Tab>"] = selectNext,
["<S-c>"] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ 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 = "copilot" },
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'luasnip' }
},
experimental = {
ghost_text = {
hl_group = "NonText",
},
},
}
end

View file

@ -0,0 +1,20 @@
return {
options = {
custom_commentstring = function() return vim.bo.commentstring end
},
mappings = {
-- Toggle comment (like `gcip` - comment inner paragraph) for both
-- Normal and Visual modes
comment = '<leader>/',
-- Toggle comment on current line
comment_line = '<leader>//',
-- Toggle comment on visual selection
comment_visual = '<leader>/',
-- Define 'comment' textobject (like `dg/` - delete whole comment block)
-- Works also in Visual mode if mapping differs from `comment_visual`
textobject = 'g/',
}
}

View file

@ -0,0 +1,18 @@
return {
keys = {
{ '<leader>ff', "<cmd>Format<cr>", desc = 'Format file' },
{ '<leader>ff', "<cmd>Format<cr>", mode = 'x', desc = 'Format selection' },
},
opts = {
format_options = {
async = true,
lsp_fallback = true,
},
notify_on_error = true,
formatters_by_ft = {
blade = { "blade-formatter" },
lua = { "stylua" },
["_"] = { "prettier" }
}
}
}

View file

@ -0,0 +1,9 @@
return {
keys = {
["<leader>la"] = { "<cmd>Laravel artisan<cr>", "Run artisan" },
["<leader>lm"] = { "<cmd>Laravel make<cr>", "Make" },
["<leader>lr"] = { "<cmd>Laravel routes<cr>", "Search routes" },
["<leader>lR"] = { "<cmd>Laravel related<cr>", "Related" },
["<leader>lv"] = { "<cmd>Laravel view-finder<cr>", "View finder" },
},
}

View file

@ -0,0 +1,74 @@
return {
mappings = {
["<leader>rs"] = { vim.lsp.buf.rename, { desc = "Rename symbol" } },
["<leader>ca"] = { vim.lsp.buf.code_action, { desc = "Code action" } },
["<leader>ff"] = { vim.lsp.buf.format, { desc = "Format file" } },
K = { vim.lsp.buf.hover, { desc = "Hover" } },
gd = { vim.lsp.buf.definition, { desc = "Goto definition" } },
gi = { vim.lsp.buf.implementation, { desc = "Goto implementation" } },
gr = { vim.lsp.buf.references, { desc = "Goto references" } },
},
servers = {
-- PHP
phpactor = {
settings = {
init_options = {
["language_server_phpstan.enabled"] = true,
["language_server_psalm.enabled"] = false,
}
}
},
--
--
-- JS,TS,VUE
volar = {
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' }
},
-- TailwindCSS
tailwindcss = {},
-- GO
gopls = {
-- format_on_save = 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,
settings = {
gopls = {
analyses = {
unusedvariable = true,
unusedwrite = true,
useany = true
},
gofumpt = true,
},
},
},
-- Lua
lua_ls = {
settings = {
Lua = {
runtime = {
version = 'LuaJIT'
},
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
}
}
},
},
},
},
}

View file

@ -0,0 +1,93 @@
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'
},
lualine_x = {
'filetype',
'fileformat',
'(vim.bo.expandtab and "SPC" or "TAB") .. " " .. vim.bo.shiftwidth',
},
lualine_y = {
separator,
'location',
'progress'
},
lualine_z = {}
},
extensions = {
'lazy',
'neo-tree'
}
}

View file

@ -0,0 +1,69 @@
local icons = require('config.icons')
return {
close_if_last_window = false,
hide_root_node = true,
default_component_configs = {
indent = {
indent_size = 2,
padding = 1,
-- indent guides
with_markers = true,
indent_marker = icons.tree.node,
last_indent_marker = icons.tree.nodelast,
},
icon = {
folder_open = icons.folder.open,
folder_close = icons.folder.close,
folder_empty = icons.folder.empty,
default = icons.files.text,
},
name = {
use_git_status_colors = false,
},
git_status = {
symbols = icons.gitsigns
},
file_size = {
enabled = false,
},
type = {
enabled = false,
},
last_modified = {
enabled = false,
},
created = {
enabled = false,
},
symlink_target = {
enabled = true,
},
},
event_handlers = {
{
event = "neo_tree_buffer_enter",
handler = function()
if vim.bo.filetype == "neo-tree" then
vim.cmd("setlocal statuscolumn=")
end
end,
}
},
filesystem = {
filtered_items = {
visible = true, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_hidden = true, -- only works on Windows for hidden files/directories
hide_by_name = {
"node_modules",
"vendor",
},
},
follow_current_file = {
enabled = true,
},
use_libuv_file_watcher = true,
}
}

View file

@ -0,0 +1,50 @@
local icons = require('config.icons')
return {
key_groups = {
["<leader>s"] = { name = "+search" },
},
keys = {
{ '<leader>sf', '<cmd>Telescope find_files<cr>', desc = 'Search files' },
{ '<leader>sa', '<cmd>Telescope live_grep<cr>', desc = 'Search in files' },
{ '<leader>sg', '<cmd>Telescope git_files<cr>', desc = 'Search Git files' },
{ '<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' },
-- LSP
{ '<leader>sr', '<cmd>Telescope lsp_references<cr>', desc = 'Search Reference' },
{ '<leader>ss', '<cmd>Telescope lsp_document_symbols<cr>', desc = 'Search document symbols' },
{ '<leader>sr', '<cmd>Telescope lsp_references<cr>', desc = 'Search Reference' },
{ '<leader>si', '<cmd>Telescope lsp_implementations<cr>', desc = 'Search Inplementations' },
{ '<leader>sp', '<cmd>Telescope lsp_workspace_symbols<cr>', desc = 'Search Workspace symbols' },
{ 'gd', '<cmd>Telescope lsp_definitions<cr>', desc = 'Goto definition' },
},
opts = function()
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/",
"node_modules/"
},
mappings = {
i = {
["<esc>"] = actions.close
}
}
},
pickers = {
find_files = {
hidden = true
}
}
}
end,
}

View file

@ -0,0 +1,57 @@
return {
-- A list of parser names
ensure_installed = {
"bash",
"c",
"cpp",
"ninja",
"cmake",
"dockerfile",
"make",
"lua",
"vim",
"vimdoc",
"query",
"php",
"phpdoc",
"blade",
"go",
"gomod",
"gosum",
"javascript",
"typescript",
"css",
"scss",
"html",
"vue",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"glsl",
"hlsl",
"markdown"
},
-- 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

@ -0,0 +1,10 @@
return {
keys = {
{ "<leader>xx", function() require("trouble").toggle() end },
{ "<leader>xw", function() require("trouble").toggle("workspace_diagnostics") end },
{ "<leader>xd", function() require("trouble").toggle("document_diagnostics") end },
{ "<leader>xq", function() require("trouble").toggle("quickfix") end },
{ "<leader>xl", function() require("trouble").toggle("loclist") end },
{ "gR", function() require("trouble").toggle("lsp_references") end },
},
}

View file

@ -0,0 +1,10 @@
return {
defaults = {
mode = { "n", "v" },
["<leader>r"] = { name = "+rename" },
["<leader>b"] = { name = "+buffers" },
["<leader>f"] = { name = "+format" },
["<leader>F"] = { name = "+files" },
["<leader>d"] = { name = "+diagnostics" }
}
}