updated files for rework v1

This commit is contained in:
Sven Vogel 2024-02-25 18:12:48 +01:00
parent 0846455551
commit 6d0e50f053
10 changed files with 258 additions and 40 deletions

View File

@ -15,3 +15,11 @@ map({ 'n', 'i' }, '<C-y>', '<cmd>redo<CR>') -- redo with STRG + y
map({ 'n', 'i' }, '<S-tab>', '<cmd><<CR>') map({ 'n', 'i' }, '<S-tab>', '<cmd><<CR>')
map({ 'n', 'i' }, '<C-g>', '<cmd>Telescope<CR>', { noremap = true }) map({ 'n', 'i' }, '<C-g>', '<cmd>Telescope<CR>', { noremap = true })
-- Scroll sideways with Shift + Scrollwheel like in browsers/other text editors
map({ 'n', 'i' }, '<S-ScrollWheelUp>', '<ScrollWheelLeft>', { noremap = true })
map({ 'n', 'i' }, '<S-ScrollWheelDown>', '<ScrollWheelRight>', { noremap = true })
map({ 'n' }, "q", "<cmd>bd<CR>", { desc = "Close buffer" })

View File

@ -18,6 +18,18 @@ return {
termguicolors = true, -- True color support termguicolors = true, -- True color support
virtualedit = "block", -- Allow cursor to move where there is no text in visual block mode virtualedit = "block", -- Allow cursor to move where there is no text in visual block mode
wrap = false, wrap = false,
foldcolumn = '1',
foldlevel = 99,
foldlevelstart = 99,
foldenable = true,
fillchars = {
foldopen = "",
foldclose = "",
fold = " ",
foldsep = " ",
diff = "",
eob = " ",
}
}, },
ui = { ui = {
theme = "vscode", theme = "vscode",

59
lua/plugins/cmp.lua Normal file
View File

@ -0,0 +1,59 @@
return {
{
'hrsh7th/nvim-cmp',
dependencies = {
-- extra completion plugins
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-calc',
'hrsh7th/cmp-emoji',
'kdheepak/cmp-latex-symbols',
-- snippets
'hrsh7th/cmp-vsnip',
'hrsh7th/vim-vsnip',
'onsails/lspkind.nvim'
},
config = function(_, opts)
local cmp = require("cmp");
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
completion = {
completeopt = "menu,menuone,noinsert",
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'buffer' },
{ name = 'calc' },
{ name = 'emoji' },
{ name = "path" },
{ name = "cmdline" },
{ name = "latex_symbols" }
}),
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, item)
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end
}
})
end
}
}

View File

@ -3,7 +3,7 @@ return {
"willothy/nvim-cokeline", "willothy/nvim-cokeline",
config = true, config = true,
opts = { opts = {
fill_hl = "BufferInactive", fill_hl = "NeoTreeTabInactive",
show_if_buffers_are_at_least = 1, show_if_buffers_are_at_least = 1,
buffers = { buffers = {
focus_on_delete = "next", focus_on_delete = "next",
@ -15,53 +15,123 @@ return {
default_hl = { default_hl = {
bg = function(buffer) bg = function(buffer)
if buffer.is_focused then if buffer.is_focused then
return "Normal" return "NeoTreeTabActive"
end end
return "BufferInactive" return "NeoTreeTabInactive"
end, end,
fg = function(buffer) fg = function(buffer)
if buffer.is_focused then if buffer.is_focused then
return "Normal" return "NeoTreeTabActive"
end end
return "BufferInactive" return "NeoTreeTabInactive"
end, end,
}, },
components = { components = {
{ {
text = ' ', text = function (buffer)
}, local text = ' '
{ if buffer.is_focused then
text = function(_) text = ''
return " " end
return text
end, end,
fg = "Normal" fg = function(buffer) return buffer.devicon.color end
}, },
{ {
text = function(buffer) return buffer.devicon.icon end, text = function(buffer) return buffer.devicon.icon end,
fg = function(buffer) return buffer.devicon.color end, fg = function(buffer) return buffer.devicon.color end,
}, },
{ {
text = function(buffer) return ' ' .. buffer.filename .. ' ' end, text = function(buffer) return buffer.filename .. ' ' end,
fg = function (buffer)
if buffer.is_focused then
if buffer.diagnostics.errors > 0 then
return "DiagnosticError"
elseif buffer.diagnostics.warnings > 0 then
return "DiagnosticWarn"
elseif buffer.diagnostics.infos > 0 then
return "DiagnosticInfo"
elseif buffer.diagnostics.hints > 0 then
return "DiagnosticHint"
end
else
return 'NeoTreeTabInactive'
end
end
},
-- show icon and number of diagnostics if there are more than one
{
text = function (buffer)
local errors = buffer.diagnostics.errors
if errors > 0 then
return require("options").lsp.icons.Error .. errors .. ' '
end
return ''
end,
fg = "DiagnosticError"
},
{
text = function (buffer)
local warns = buffer.diagnostics.warnings
if warns > 0 then
return require("options").lsp.icons.Warn .. warns .. ' '
end
return ''
end,
fg = function (buffer)
if not buffer.is_focused then
return 'NeoTreeTabInactive'
end
return "DiagnosticWarn"
end
},
{
text = function (buffer)
local infos = buffer.diagnostics.infos
if infos > 0 then
return require("options").lsp.icons.Info .. infos .. ' '
end
return ''
end,
fg = function (buffer)
if not buffer.is_focused then
return 'NeoTreeTabInactive'
end
return "DiagnosticInfo"
end
},
{
text = function (buffer)
local hints = buffer.diagnostics.hints
if hints > 0 then
return require("options").lsp.icons.Hint .. hints .. ' '
end
return ''
end,
fg = function (buffer)
if not buffer.is_focused then
return 'NeoTreeTabInactive'
end
return "DiagnosticHint"
end
}, },
{ {
text = ' ', text = ' ',
}, },
{ {
text = function(buffer) text = function(buffer)
local text = "󰅖"
if buffer.is_modified then if buffer.is_modified then
return '' text = ''
elseif buffer.is_readonly then elseif buffer.is_readonly then
return '' text = ''
else
return '󰅖'
end end
return text .. ' '
end, end,
on_click = function(_, _, _, _, buffer) on_click = function(_, _, _, _, buffer)
buffer:delete() buffer:delete()
end end
},
{
text = ' ',
} }
}, },
tabs = { tabs = {
@ -73,15 +143,15 @@ return {
end, end,
bg = function(tabpage) bg = function(tabpage)
if tabpage.is_active then if tabpage.is_active then
return "Normal" return "NeoTreeTabActive"
end end
return "BufferInactive" return "NeoTreeTabInactive"
end, end,
fg = function(tabpage) fg = function(tabpage)
if tabpage.is_active then if tabpage.is_active then
return "Normal" return "NeoTreeTabActive"
end end
return "BufferInactive" return "NeoTreeTabInactive"
end end
}, },
{ {
@ -95,10 +165,10 @@ return {
tabpage:close() tabpage:close()
end, end,
bg = function(_) bg = function(_)
return "Normal" return "NeoTreeTabActive"
end, end,
fg = function(_) fg = function(_)
return "Normal" return "NeoTreeTabActive"
end end
} }
}, },
@ -108,8 +178,8 @@ return {
components = { components = {
{ {
text = "", text = "",
bg = "Normal", bg = "NeoTreeTabInactive",
fg = "Normal" fg = "NeoTreeTabInactive"
} }
}, },
}, },

View File

@ -29,10 +29,8 @@ return {
local options = require("options") local options = require("options")
require("mason").setup() require("mason").setup()
require("mason-lspconfig").setup()
-- automatically register lsp handler installed with mason local handlers = {
require("mason-lspconfig").setup_handlers {
-- The first entry (without a key) will be the default handler -- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have -- and will be called for each installed server that doesn't have
-- a dedicated handler. -- a dedicated handler.
@ -41,6 +39,8 @@ return {
end, end,
} }
require("mason-lspconfig").setup({ handlers = handlers })
-- set custom icons -- set custom icons
for name, icon in pairs(options.lsp.icons) do for name, icon in pairs(options.lsp.icons) do
name = "DiagnosticSign" .. name name = "DiagnosticSign" .. name

View File

@ -23,7 +23,9 @@ return {
modified = '~', modified = '~',
removed = '-', removed = '-',
} }
}
}, },
lualine_c = {
{ {
'diagnostics', 'diagnostics',
symbols = { symbols = {
@ -36,14 +38,12 @@ return {
'nvim_diagnostic' 'nvim_diagnostic'
}, },
update_in_insert = true update_in_insert = true
}
}, },
lualine_c = {
{ {
'filename', 'filename',
symbols = { symbols = {
modified = '[+]', -- Text to show when the file is modified. modified = '', -- Text to show when the file is modified.
readonly = '[-]', -- Text to show when the file is non-modifiable or readonly. readonly = '', -- Text to show when the file is non-modifiable or readonly.
unnamed = '', -- Text to show for unnamed buffers. unnamed = '', -- Text to show for unnamed buffers.
newfile = '[New]', -- Text to show for newly created file before first write newfile = '[New]', -- Text to show for newly created file before first write
} }
@ -79,7 +79,17 @@ return {
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
lualine_b = {}, lualine_b = {},
lualine_c = {'filename'}, lualine_c = {
{
'filename',
symbols = {
modified = '', -- Text to show when the file is modified.
readonly = '', -- Text to show when the file is non-modifiable or readonly.
unnamed = '', -- Text to show for unnamed buffers.
newfile = '[New]', -- Text to show for newly created file before first write
}
}
},
lualine_x = {'location'}, lualine_x = {'location'},
lualine_y = {}, lualine_y = {},
lualine_z = {} lualine_z = {}

View File

@ -11,6 +11,15 @@ return {
local options = require("options") local options = require("options")
return { return {
sources = {
"filesystem",
"buffers",
"document_symbols"
},
source_selector = {
winbar = true,
statusline = false
},
popup_border_style = options.ui.border, popup_border_style = options.ui.border,
default_component_configs = { default_component_configs = {
container = { container = {
@ -60,7 +69,13 @@ return {
enabled = true, enabled = true,
leave_dirs_open = true leave_dirs_open = true
} }
} },
buffers = {
follow_current_file = {
enabled = true, -- This will find and focus the file in the active buffer every time
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
},
},
} }
end end
} }

View File

@ -16,6 +16,7 @@ return {
winblend = 0, winblend = 0,
}, },
extensions = { extensions = {
'fzf'
} }
} }
}, },

View File

@ -5,6 +5,9 @@ return {
event = { event = {
"VeryLazy" "VeryLazy"
}, },
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
},
init = function(plugin) init = function(plugin)
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
@ -25,7 +28,22 @@ return {
return true return true
end end
end, end,
} },
indent = {
enable = true
},
autotag = {
enable = true
},
textobjects = {
move = {
enable = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
},
}, },
config = function(_, opts) config = function(_, opts)
require("nvim-treesitter.configs").setup(opts) require("nvim-treesitter.configs").setup(opts)

25
lua/plugins/ufo.lua Normal file
View File

@ -0,0 +1,25 @@
return {
{
"kevinhwang91/nvim-ufo",
event = {
"InsertEnter"
},
dependencies = {
"kevinhwang91/promise-async"
},
opts = {
preview = {
mappings = {
scrollB = "<C-b>",
scrollF = "<C-f>",
scrollU = "<C-u>",
scrollD = "<C-d>",
},
},
-- register treesitter as source for scopes
provider_selector = function(_, _, _)
return { 'treesitter', 'indent' }
end
}
}
}