Refactore nvim config
This commit is contained in:
476
nvim/lua/plugins.lua
Normal file
476
nvim/lua/plugins.lua
Normal file
@@ -0,0 +1,476 @@
|
||||
-- vim.g.delimitMate_expand_space=1
|
||||
-- vim.g.delimitMate_expand_cr = 1
|
||||
|
||||
require('mini.pairs').setup()
|
||||
require('mini.align').setup()
|
||||
require('mini.bracketed').setup()
|
||||
require('mini.splitjoin').setup()
|
||||
require('mini.move').setup()
|
||||
require('mini.move').setup()
|
||||
require('flash').setup()
|
||||
require('ts-comments').setup()
|
||||
|
||||
vim.g.tagbar_left=1
|
||||
vim.g.tagbar_autoclose=1
|
||||
vim.g.tagbar_autofocus=1
|
||||
|
||||
vim.g.windowswap_map_keys=0
|
||||
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('lspkind')
|
||||
local ls = require('luasnip')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
ls.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
|
||||
-- mapping = cmp.mapping.preset.insert({
|
||||
-- -- ['<Tab>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
-- }),
|
||||
mapping = {
|
||||
['<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(function(fallback)
|
||||
if cmp.visible() then
|
||||
if cmp.get_selected_entry() then
|
||||
if ls.expandable() then
|
||||
ls.expand()
|
||||
else
|
||||
cmp.confirm({
|
||||
select = false,
|
||||
})
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif ls.locally_jumpable(1) then
|
||||
ls.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif ls.locally_jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp', priority = 1000 },
|
||||
{ name = 'buffer', priority = 800, keyword_length = 2 },
|
||||
{ name = 'copilot', priority = 700 },
|
||||
{ name = 'path', priority = 600 },
|
||||
{ name = 'cmp_yanky', priority = 500 },
|
||||
{ name = 'git', priority = 400 },
|
||||
{ name = 'luasnip', priority = 300 },
|
||||
{ name = 'nvim_lua', priority = 200 },
|
||||
}),
|
||||
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
-- mode = "symbol_text",
|
||||
mode = "symbol",
|
||||
menu = ({
|
||||
buffer = "[buf]",
|
||||
nvim_lsp = "[lsp]",
|
||||
vsnip = "[snip]",
|
||||
nvim_lua = "[lua]",
|
||||
latex_symbols = "[tex]",
|
||||
path = "[path]",
|
||||
cmp_yanky = "[yank]",
|
||||
copilot = "[copilot]",
|
||||
}),
|
||||
symbol_map = { Copilot = "" }
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
-- -- Set configuration for specific filetype.
|
||||
-- cmp.setup.filetype('gitcommit', {
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
-- }, {
|
||||
-- { name = 'buffer' },
|
||||
-- })
|
||||
-- })
|
||||
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false }
|
||||
})
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true
|
||||
}
|
||||
|
||||
local language_servers = vim.lsp.get_clients() -- or list servers manually like {'gopls', 'clangd'}
|
||||
for _, ls in ipairs(language_servers) do
|
||||
if ls ~= nil then
|
||||
vim.lsp.config(ls).setup({
|
||||
capabilities = capabilities
|
||||
-- you can add other fields for setting up lsp server in this table
|
||||
})
|
||||
end
|
||||
end
|
||||
require('ufo').setup()
|
||||
|
||||
require("yanky").setup({
|
||||
ring = {
|
||||
history_length = 100,
|
||||
storage = "shada",
|
||||
sync_with_numbered_registers = true,
|
||||
cancel_event = "update",
|
||||
},
|
||||
system_clipboard = {
|
||||
sync_with_ring = true,
|
||||
},
|
||||
preserve_cursor_position = {
|
||||
enabled = true,
|
||||
},
|
||||
})
|
||||
|
||||
require("telescope").setup {
|
||||
extensions = {
|
||||
["ui-select"] = {
|
||||
require("telescope.themes").get_dropdown {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
require("telescope").load_extension("ui-select")
|
||||
require("telescope").load_extension("yank_history")
|
||||
|
||||
-- require'nvim-treesitter.configs'.setup {
|
||||
-- -- ensure_installed = { "lua", "vim", "help" },
|
||||
-- ensure_installed = {},
|
||||
-- sync_install = false,
|
||||
-- auto_install = false,
|
||||
--
|
||||
--
|
||||
-- highlight = {
|
||||
-- enable = true,
|
||||
--
|
||||
-- disable = function(lang, buf)
|
||||
-- local max_filesize = 100 * 1024 -- 100 KB
|
||||
-- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
-- if ok and stats and stats.size > max_filesize then
|
||||
-- return true
|
||||
-- end
|
||||
-- end,
|
||||
--
|
||||
-- additional_vim_regex_highlighting = false,
|
||||
-- },
|
||||
-- }
|
||||
|
||||
require('lualine').setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'Tomorrow',
|
||||
component_separators = { left = '', right = ''},
|
||||
section_separators = { left = '', right = ''},
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = true,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
})
|
||||
|
||||
|
||||
require("copilot").setup({
|
||||
suggestion = { enabled = false },
|
||||
panel = { enabled = false },
|
||||
})
|
||||
require("copilot_cmp").setup()
|
||||
require("CopilotChat").setup {
|
||||
model = 'claude-3.7-sonnet',
|
||||
}
|
||||
|
||||
vim.g.bullets_enabled_file_types = {
|
||||
'markdown',
|
||||
'text',
|
||||
'gitcommit',
|
||||
'scratch'
|
||||
}
|
||||
|
||||
|
||||
require("nvim-tree").setup({
|
||||
sort = {
|
||||
sorter = "case_sensitive",
|
||||
},
|
||||
view = {
|
||||
width = 30,
|
||||
},
|
||||
renderer = {
|
||||
group_empty = true,
|
||||
},
|
||||
-- filters = {
|
||||
-- dotfiles = true,
|
||||
-- },
|
||||
})
|
||||
|
||||
require('gitsigns').setup {
|
||||
signs = {
|
||||
add = { text = '┃' },
|
||||
change = { text = '┃' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
untracked = { text = '┆' },
|
||||
},
|
||||
signs_staged = {
|
||||
add = { text = '┃' },
|
||||
change = { text = '┃' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
untracked = { text = '┆' },
|
||||
},
|
||||
signs_staged_enable = true,
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
watch_gitdir = {
|
||||
follow_files = true
|
||||
},
|
||||
auto_attach = true,
|
||||
attach_to_untracked = false,
|
||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
virt_text_priority = 100,
|
||||
use_focus = true,
|
||||
},
|
||||
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000, -- Disable if file is longer than this (in lines)
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
style = 'minimal',
|
||||
relative = 'cursor',
|
||||
row = 0,
|
||||
col = 1
|
||||
},
|
||||
}
|
||||
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
python = {"ruff_fix", "ruff_format", "ruff_organize_imports", lsp_format = "fallback"},
|
||||
rust = {"rustfmt", lsp_format = "fallback"},
|
||||
go = {"gofmt", "goimports", lsp_format = "fallback"},
|
||||
lua = { "stylua", lsp_format = "fallback"},
|
||||
},
|
||||
})
|
||||
require('lint').linters_by_ft = {
|
||||
markdown = {'vale'},
|
||||
}
|
||||
require("trouble").setup()
|
||||
require("todo-comments").setup()
|
||||
|
||||
require("dapui").setup()
|
||||
require("nvim-dap-virtual-text").setup()
|
||||
|
||||
local dap, dapui = require("dap"), require("dapui")
|
||||
dap.listeners.before.attach.dapui_config = function()
|
||||
dapui.open()
|
||||
end
|
||||
dap.listeners.before.launch.dapui_config = function()
|
||||
dapui.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated.dapui_config = function()
|
||||
dapui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited.dapui_config = function()
|
||||
dapui.close()
|
||||
end
|
||||
|
||||
dap.adapters.codelldb = {
|
||||
type = 'server',
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = "codelldb",
|
||||
args = {"--port", "${port}"},
|
||||
}
|
||||
}
|
||||
|
||||
dap.configurations.zig = {
|
||||
{
|
||||
name = "Launch Zig Program",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
-- Prompts for the executable path when you start debugging
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/zig-out/bin/', 'file')
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
},
|
||||
}
|
||||
|
||||
if _G.is_mac then
|
||||
workspaces = {
|
||||
{
|
||||
name = "privat",
|
||||
path = "~/Documents/notes/privat",
|
||||
},
|
||||
{
|
||||
name = "joplin",
|
||||
path = "~/Documents/notes/fromjoplin",
|
||||
},
|
||||
}
|
||||
daily_notes = {
|
||||
folder = "Journal",
|
||||
date_format = "%Y-%m-%d",
|
||||
default_tags = { "journal" },
|
||||
template = "daily.md"
|
||||
}
|
||||
end
|
||||
|
||||
if _G.is_work then
|
||||
workspaces = {
|
||||
{
|
||||
name = "work",
|
||||
path = "/mnt/c/Users/marti/Documents/notes/Work",
|
||||
},
|
||||
{
|
||||
name = "privat",
|
||||
path = "/mnt/c/Users/marti/Documents/notes/privat",
|
||||
},
|
||||
}
|
||||
daily_notes = {}
|
||||
end
|
||||
|
||||
require("obsidian").setup({
|
||||
workspaces = workspaces,
|
||||
templates = {
|
||||
folder = "_templates",
|
||||
date_format = "%Y-%m-%d %a",
|
||||
time_format = "%H:%M",
|
||||
},
|
||||
checkbox = {
|
||||
order = { " ", ">", "x", "!", "~" },
|
||||
},
|
||||
frontmatter = {
|
||||
enabled = true,
|
||||
func = function(note)
|
||||
-- Add the title of the note as an alias.
|
||||
if note.title then
|
||||
note:add_alias(note.title)
|
||||
end
|
||||
|
||||
local out = { id = note.id, tags = note.tags }
|
||||
|
||||
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
|
||||
for k, v in pairs(note.metadata) do
|
||||
out[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
return out
|
||||
end,
|
||||
},
|
||||
note_path_func = function(spec)
|
||||
local path = spec.dir / spec.title
|
||||
return path:with_suffix(".md")
|
||||
end,
|
||||
daily_notes = daily_notes,
|
||||
legacy_commands = false,
|
||||
})
|
||||
|
||||
require('render-markdown').setup({
|
||||
enabled = true,
|
||||
file_types = { 'markdown'},
|
||||
completions = { lsp = { enabled = true } },
|
||||
render_modes = { 'n', 'c', 't' },
|
||||
checkbox = {
|
||||
enabled = true,
|
||||
render_modes = false,
|
||||
bullet = false,
|
||||
right_pad = 1,
|
||||
unchecked = {
|
||||
icon = ' ',
|
||||
highlight = 'RenderMarkdownUnchecked',
|
||||
scope_highlight = nil,
|
||||
},
|
||||
checked = {
|
||||
icon = ' ',
|
||||
highlight = 'RenderMarkdownChecked',
|
||||
scope_highlight = nil,
|
||||
},
|
||||
custom = {
|
||||
next = { raw = '[!]', rendered = ' ', highlight = 'RenderMarkdownNext', scope_highlight = nil },
|
||||
ongoing = { raw = '[>]', rendered = '▶ ', highlight = 'RenderMarkdownOngoing', scope_highlight = nil },
|
||||
waiting = { raw = '[~]', rendered = ' ', highlight = 'RenderMarkdownWaiting', scope_highlight = nil },
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user