Updated files

This commit is contained in:
Christoffer Martinsson 2025-05-15 21:10:39 +02:00
parent 284b8adee8
commit b024bd69e3
3 changed files with 408 additions and 627 deletions

View File

@ -112,14 +112,11 @@ require("lazy").setup({
},
-- LSP ----------------------------------------------------
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
@ -165,61 +162,10 @@ require("lazy").setup({
return client.supports_method(method, { bufnr = bufnr })
end
end
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
-- if
-- client
-- and client_supports_method(
-- client,
-- vim.lsp.protocol.Methods.textDocument_documentHighlight,
-- event.buf
-- )
-- then
-- local highlight_augroup =
-- vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
-- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
-- buffer = event.buf,
-- group = highlight_augroup,
-- callback = vim.lsp.buf.document_highlight,
-- })
--
-- vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
-- buffer = event.buf,
-- group = highlight_augroup,
-- callback = vim.lsp.buf.clear_references,
-- })
--
-- vim.api.nvim_create_autocmd("LspDetach", {
-- group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
-- callback = function(event2)
-- vim.lsp.buf.clear_references()
-- vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
-- end,
-- })
-- end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if
client
and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf)
then
map("<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, "[T]oggle Inlay [H]ints")
end
end,
})
-- Diagnostic Config
-- See :help vim.diagnostic.Opts
vim.diagnostic.config({
severity_sort = true,
float = { border = "rounded", source = "if_many" },
@ -263,8 +209,6 @@ require("lazy").setup({
completion = {
callSnippet = "Replace",
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
@ -276,12 +220,13 @@ require("lazy").setup({
end
end,
},
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
lua = { "stylua" },
python = { "isort", "black", timeout_ms = 3000 },
python = { "isort", "black" },
rust = { "rustfmt", lsp_format = "fallback" },
c = { "clang_format" },
cpp = { "clang_format" },
@ -304,7 +249,7 @@ require("lazy").setup({
},
},
format_on_save = {
timeout_ms = 500,
timeout_ms = 3000,
lsp_format = "fallback",
},
},
@ -392,180 +337,15 @@ require("lazy").setup({
"ibhagwan/fzf-lua",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
},
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
opts = {
close_if_last_window = true,
popup_border_style = "rounded",
enable_git_status = true,
enable_diagnostics = true,
open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes
sort_case_insensitive = false, -- used when sorting files and directories in the tree
sort_function = nil, -- use a custom function for sorting files and directories in the tree
default_component_configs = {
container = {
enable_character_fade = true,
},
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
-- indent guides
with_markers = true,
indent_marker = "",
last_indent_marker = "",
highlight = "NeoTreeIndentMarker",
-- expander config, needed for nesting files
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
icon = {
folder_closed = "",
folder_open = "",
folder_empty_open = "",
folder_empty = "󰜌",
provider = function(icon, node, state) -- default icon provider utilizes nvim-web-devicons if available
if node.type == "file" or node.type == "terminal" then
local success, web_devicons = pcall(require, "nvim-web-devicons")
local name = node.type == "terminal" and "terminal" or node.name
if success then
local devicon, hl = web_devicons.get_icon(name)
icon.text = devicon or icon.text
icon.highlight = hl or icon.highlight
end
end
end,
-- 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 = "*",
highlight = "NeoTreeFileIcon",
},
modified = {
symbol = "[+]",
highlight = "NeoTreeModified",
},
name = {
trailing_slash = false,
use_git_status_colors = true,
highlight = "NeoTreeFileName",
},
git_status = {
symbols = {
-- Change type
added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
deleted = "", -- this can only be used in the git_status source
renamed = "󰁕", -- this can only be used in the git_status source
-- Status type
untracked = "",
ignored = "",
unstaged = "󰄱",
staged = "",
conflict = "",
},
},
-- -- If you don't want to use these columns, you can set `enabled = false` for each of them individually
-- file_size = {
-- enabled = true,
-- required_width = 64, -- min width of window required to show this column
-- },
-- type = {
-- enabled = true,
-- required_width = 122, -- min width of window required to show this column
-- },
-- last_modified = {
-- enabled = true,
-- required_width = 88, -- min width of window required to show this column
-- },
-- created = {
-- enabled = true,
-- required_width = 110, -- min width of window required to show this column
-- },
-- symlink_target = {
-- enabled = false,
-- },
},
commands = {
parent_or_close = function(state)
local node = state.tree:get_node()
if (node.type == "directory" or node:has_children()) and node:is_expanded() then
state.commands.toggle_node(state)
else
require("neo-tree.ui.renderer").focus_node(state, node:get_parent_id())
end
end,
child_or_open = function(state)
local node = state.tree:get_node()
if node.type == "directory" or node:has_children() then
if not node:is_expanded() then -- if unexpanded, expand
state.commands.toggle_node(state)
else -- if expanded and has children, seleect the next child
require("neo-tree.ui.renderer").focus_node(state, node:get_child_ids()[1])
end
else -- if not a directory just open it
state.commands.open(state)
end
end,
copy_selector = function(state)
local node = state.tree:get_node()
local filepath = node:get_id()
local filename = node.name
local modify = vim.fn.fnamemodify
local results = {
e = { val = modify(filename, ":e"), msg = "Extension only" },
f = { val = filename, msg = "Filename" },
F = { val = modify(filename, ":r"), msg = "Filename w/o extension" },
h = { val = modify(filepath, ":~"), msg = "Path relative to Home" },
p = { val = modify(filepath, ":."), msg = "Path relative to CWD" },
P = { val = filepath, msg = "Absolute path" },
}
local messages = {
{ "\nChoose to copy to clipboard:\n", "Normal" },
}
for i, result in pairs(results) do
if result.val and result.val ~= "" then
vim.list_extend(messages, {
{ ("%s."):format(i), "Identifier" },
{ (" %s: "):format(result.msg) },
{ result.val, "String" },
{ "\n" },
})
end
end
vim.api.nvim_echo(messages, false, {})
local result = results[vim.fn.getcharstr()]
if result and result.val and result.val ~= "" then
vim.notify("Copied: " .. result.val)
vim.fn.setreg("+", result.val)
end
end,
},
window = {
position = "float",
width = 40,
mappings = {
["<space>"] = false, -- disable space until we figure out which-key disabling
h = "parent_or_close",
l = "child_or_open",
Y = "copy_selector",
},
fzf_opts = {
["--bind"] = {
"ctrl-n:down",
"ctrl-p:up",
},
},
},
-- GUI ------------------------------------------------------
{
"mrjones2014/smart-splits.nvim",
opts = {
@ -614,6 +394,18 @@ require("lazy").setup({
},
},
{ "echasnovski/mini.icons", version = "*", opts = {} },
{ "echasnovski/mini.pairs", version = "*", opts = {} },
{
"echasnovski/mini.files",
version = "*",
opts = { mappings = {
go_in_plus = "l",
go_out = "h",
go_out_plus = "H",
} },
},
{
"lewis6991/gitsigns.nvim",
opts = {
@ -648,7 +440,7 @@ require("lazy").setup({
{
"norcalli/nvim-colorizer.lua",
opts = {},
opts = { "*" },
},
{
@ -696,15 +488,15 @@ require("lazy").setup({
}, {})
-- resizing splits
vim.keymap.set({ "n", "t" }, "<C-A-h>", require("smart-splits").resize_left, { desc = "Resize left" })
vim.keymap.set({ "n", "t" }, "<C-A-j>", require("smart-splits").resize_down, { desc = "Resize down" })
vim.keymap.set({ "n", "t" }, "<C-A-k>", require("smart-splits").resize_up, { desc = "Resize up" })
vim.keymap.set({ "n", "t" }, "<C-A-l>", require("smart-splits").resize_right, { desc = "Resize right" })
vim.keymap.set({ "n", "t" }, "<A-h>", require("smart-splits").resize_left, { desc = "Resize left" })
vim.keymap.set({ "n", "t" }, "<A-j>", require("smart-splits").resize_down, { desc = "Resize down" })
vim.keymap.set({ "n", "t" }, "<A-k>", require("smart-splits").resize_up, { desc = "Resize up" })
vim.keymap.set({ "n", "t" }, "<A-l>", require("smart-splits").resize_right, { desc = "Resize right" })
-- moving between splits
vim.keymap.set({ "n", "t" }, "<A-h>", require("smart-splits").move_cursor_left, { desc = "Move cursor left" })
vim.keymap.set({ "n", "t" }, "<A-j>", require("smart-splits").move_cursor_down, { desc = "Move cursor down" })
vim.keymap.set({ "n", "t" }, "<A-k>", require("smart-splits").move_cursor_up, { desc = "Move cursor up" })
vim.keymap.set({ "n", "t" }, "<A-l>", require("smart-splits").move_cursor_right, { desc = "Move cursor right" })
vim.keymap.set({ "n", "t" }, "<C-h>", require("smart-splits").move_cursor_left, { desc = "Move cursor left" })
vim.keymap.set({ "n", "t" }, "<C-j>", require("smart-splits").move_cursor_down, { desc = "Move cursor down" })
vim.keymap.set({ "n", "t" }, "<C-k>", require("smart-splits").move_cursor_up, { desc = "Move cursor up" })
vim.keymap.set({ "n", "t" }, "<C-l>", require("smart-splits").move_cursor_right, { desc = "Move cursor right" })
-- swapping buffers between windows
vim.keymap.set("n", "<leader><leader>h", require("smart-splits").swap_buf_left, { desc = "Swap buffer left" })
vim.keymap.set("n", "<leader><leader>j", require("smart-splits").swap_buf_down, { desc = "Swap buffer down" })
@ -717,19 +509,12 @@ vim.keymap.set({ "n", "v" }, "d", '"+d', { noremap = true, silent = true })
-- vim.keymap.set({ 'n', 'v' }, 'x', '"+x', { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "p", '"+p', { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "P", '"+P', { noremap = true, silent = true })
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
--Other
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
vim.keymap.set("n", "s", ":HopWord<cr>", { desc = "hop", silent = true })
vim.keymap.set("n", "<tab>", ":tabNext<cr>", { desc = "Next tab", silent = true })
vim.keymap.set("n", "<C-s>", ":write<cr>", { desc = "Save", silent = true })
vim.keymap.set("n", "<C-q>", ":quit<cr>", { desc = "Quit", silent = true })
vim.keymap.set(
"n",
"<leader>e",
":Neotree filesystem reveal float toggle<cr>",
{ desc = "File explorer", silent = true }
)
vim.keymap.set("n", "<leader>e", ":e .<cr>", { desc = "File explorer", silent = true })
vim.keymap.set("n", "<leader>d", ":Trouble diagnostics toggle<cr>", { desc = "Diagnostic view", silent = true })
vim.keymap.set("n", "<leader>f", ":FzfLua files cwd=~/<cr>", { desc = "Find file", silent = true })

View File

@ -52,7 +52,7 @@ function theme.setup()
Label = { fg = p.color4 },
LineNr = { fg = p.color17 },
Macro = { fg = p.color6 },
MatchParen = { fg = p.color4, bg = p.background },
MatchParen = { bg = p.color17 },
ModeMsg = { fg = p.foreground, bg = p.background },
MoreMsg = { fg = p.color5 },
MsgArea = { fg = p.foreground, bg = p.background },

View File

@ -18,26 +18,24 @@ set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
# Optional configurations with their default values if omitted:
set -g @smart-splits_no_wrap '' # to disable wrapping. (any value disables wrapping)
set -g @smart-splits_move_left_key 'M-h' # key-mapping for navigation.
set -g @smart-splits_move_down_key 'M-j' # --"--
set -g @smart-splits_move_up_key 'M-k' # --"--
set -g @smart-splits_move_right_key 'M-l' # --"--
set -g @smart-splits_move_left_key 'C-h' # key-mapping for navigation.
set -g @smart-splits_move_down_key 'C-j' # --"--
set -g @smart-splits_move_up_key 'C-k' # --"--
set -g @smart-splits_move_right_key 'C-l' # --"--
set -g @smart-splits_resize_left_key 'C-M-h' # key-mapping for resizing.
set -g @smart-splits_resize_down_key 'C-M-j' # --"--
set -g @smart-splits_resize_up_key 'C-M-k' # --"--
set -g @smart-splits_resize_right_key 'C-M-l' # --"--
set -g @smart-splits_resize_left_key 'M-h' # key-mapping for resizing.
set -g @smart-splits_resize_down_key 'M-j' # --"--
set -g @smart-splits_resize_up_key 'M-k' # --"--
set -g @smart-splits_resize_right_key 'M-l' # --"--
set -g @smart-splits_resize_step_size '3' # change the step-size for resizing.
bind -n M-Left split-window -h -b -c "#{pane_current_path}"
bind -n M-Right split-window -h -c "#{pane_current_path}"
bind -n M-Down split-window -v -c "#{pane_current_path}"
bind -n M-Up split-window -v -b -c "#{pane_current_path}"
bind -n C-M-h split-window -h -b -c "#{pane_current_path}"
bind -n C-M-l split-window -h -c "#{pane_current_path}"
bind -n C-M-j split-window -v -c "#{pane_current_path}"
bind -n C-M-k split-window -v -b -c "#{pane_current_path}"
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
@ -49,9 +47,7 @@ bind -n M-n select-window -n
bind -n M-c new-window
bind -n M-x confirm kill-pane
bind -n M-g display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "lazygit"
bind -n M-t display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "btop"
bind -n M-f display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "EDITOR=nvim ranger"
bind -n C-g display-popup -d "#{pane_current_path}" -E -w 90% -h 90% "lazygit"
set-option -g status-position top
set-option -g default-terminal "tmux-256color"