This commit is contained in:
Christoffer Martinsson 2024-10-20 12:56:32 +02:00
parent ffbafeb70a
commit ba8be253c5

View File

@ -2,6 +2,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
-- Set highlight on search -- Set highlight on search
vim.o.hlsearch = false vim.o.hlsearch = false
@ -53,7 +54,6 @@ vim.o.wrap = true
vim.o.foldmethod = "expr" vim.o.foldmethod = "expr"
vim.o.foldexpr = "nvim_treesitter#foldexpr()" vim.o.foldexpr = "nvim_treesitter#foldexpr()"
-- vim.o.nofoldenable = true
vim.o.foldlevelstart = 99 vim.o.foldlevelstart = 99
-- show cursor line only in active window -- show cursor line only in active window
@ -70,6 +70,14 @@ vim.api.nvim_create_autocmd(
-- Auto format on save -- Auto format on save
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
-- Auto update on file changes
vim.o.autoread = true
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, {
command = "if mode() != 'c' | checktime | endif",
pattern = { "*" },
})
vim.api.nvim_create_autocmd({ "FileChangedShellPost" },
{ command = 'echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None', pattern = { "*" }, })
------------------------------------------------------------------- -------------------------------------------------------------------
-- Plugin management -- Plugin management
------------------------------------------------------------------- -------------------------------------------------------------------
@ -235,6 +243,40 @@ require('lazy').setup({
}, },
}, },
{
's1n7ax/nvim-window-picker',
version = '2.*',
config = function()
require 'window-picker'.setup({
filter_rules = {
include_current_win = false,
autoselect_one = true,
-- filter using buffer options
bo = {
-- if the file type is one of following, the window will be ignored
filetype = { 'neo-tree', "neo-tree-popup", "notify" },
-- if the buffer type is one of following, the window will be ignored
buftype = { 'terminal', "quickfix" },
},
},
highlights = {
statusline = {
unfocused = {
fg = '#d7af5f',
bg = '#262626',
bold = true,
},
focused = {
fg = '#d7af5f',
bg = '#262626',
bold = true,
},
},
},
})
end,
},
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
branch = "v3.x", branch = "v3.x",
@ -242,45 +284,12 @@ require('lazy').setup({
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
{
's1n7ax/nvim-window-picker',
version = '2.*',
config = function()
require 'window-picker'.setup({
filter_rules = {
include_current_win = false,
autoselect_one = true,
-- filter using buffer options
bo = {
-- if the file type is one of following, the window will be ignored
filetype = { 'neo-tree', "neo-tree-popup", "notify" },
-- if the buffer type is one of following, the window will be ignored
buftype = { 'terminal', "quickfix" },
},
},
highlights = {
statusline = {
unfocused = {
fg = '#d7af5f',
bg = '#262626',
bold = true,
},
focused = {
fg = '#d7af5f',
bg = '#262626',
bold = true,
},
},
},
})
end,
},
}, },
config = function() config = function()
require("neo-tree").setup { require("neo-tree").setup {
close_if_last_window = true, close_if_last_window = true,
popup_border_style = "rounded", popup_border_style = "rounded",
enable_git_status = true, enable_git_status = false,
enable_diagnostics = 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 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_case_insensitive = false, -- used when sorting files and directories in the tree
@ -1017,11 +1026,3 @@ vim.keymap.set('n', '<leader>c', ":tabclose<cr>", { desc = 'Format code', silent
vim.keymap.set('n', '<leader>e', ":Neotree filesystem reveal float toggle<cr>", { desc = 'File explorer', silent = true }) vim.keymap.set('n', '<leader>e', ":Neotree filesystem reveal float toggle<cr>", { desc = 'File explorer', silent = true })
vim.keymap.set('n', 's', ":HopWord<cr>", { desc = 'hop', silent = true }) vim.keymap.set('n', 's', ":HopWord<cr>", { desc = 'hop', silent = true })
vim.keymap.set('n', '<leader>t', ":TroubleToggle<cr>", { desc = 'Trouble view', silent = true }) vim.keymap.set('n', '<leader>t', ":TroubleToggle<cr>", { desc = 'Trouble view', silent = true })
vim.o.autoread = true
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, {
command = "if mode() != 'c' | checktime | endif",
pattern = { "*" },
})
vim.api.nvim_create_autocmd({ "FileChangedShellPost" },
{ command = 'echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None', pattern = { "*" }, })