1
0
Fork 0
dotfiles/.config/nvim/lua/my/tools.lua

154 lines
4.6 KiB
Lua

require('which-key').setup({})
local map = require('my.functions').map
local telescope = require('telescope')
local t_actions = require('telescope.actions')
telescope.load_extension('projects')
telescope.load_extension('dap')
telescope.load_extension('fzf')
telescope.setup({
mappings = {
i = {
["<C-_>"] = t_actions.which_key,
},
n = {
["?"] = t_actions.which_key,
}
},
defaults = {
file_ignore_patterns = { '^\\.git', '^fun' },
},
pickers = {
find_files = {
-- show hidden files by default
find_command = { "rg", "--files", "--hidden", "--glob", "!.git/*" }
}
}
})
local t_builtin = require('telescope.builtin')
local my = require('my.functions')
require('which-key').register({ ['<Leader>t'] = { name = 'Telescope' } })
map('n', '<Leader>tb', t_builtin.buffers, 'Buffers')
map('n', '<Leader>tf', function()
t_builtin.find_files({ cwd = my.get_project_root() })
end, 'Files')
map('n', '<Leader>tF', t_builtin.find_files, 'Files in cwd')
map('n', '<Leader>to', t_builtin.oldfiles, 'Recently opened files')
map('n', '<Leader>tg', function()
t_builtin.live_grep({ cwd = my.get_project_root() })
end, 'Live-grep')
map('n', '<Leader>tm', t_builtin.man_pages, 'Man pages')
map('n', '<Leader>tr', t_builtin.registers, 'Registers')
map('n', '<Leader>gh', t_builtin.git_bcommits, 'History of this file')
map('n', '<F7>', t_builtin.diagnostics, 'Show diagnostics')
map('n', '<Leader>tp', telescope.extensions.projects.projects, 'Projects')
map('n', '<Leader>tt',
require("telescope._extensions.todo-comments").exports.todo,
'Display TODO comments in project')
map('n', '<Leader>tn', telescope.extensions.notify.notify, 'Notifications')
local nerdfont_installed = require('my.functions').nerdfont_installed()
require("nvim-tree").setup({
filters = {
dotfiles = false,
custom = { '^\\.git' }
},
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true
},
renderer = {
icons = {
show = {
file = nerdfont_installed,
folder = nerdfont_installed,
folder_arrow = nerdfont_installed,
git = nerdfont_installed
}
}
}
})
map('n', '<F9>', require("nvim-tree.api").tree.toggle, 'Open nvim-tree')
map('i', '<F9>', require("nvim-tree.api").tree.toggle, 'Open nvim-tree')
vim.o.showmode = false
local not_firenvim = require('my.functions').not_firenvim
require('lualine').setup({
options = {
icons_enabled = nerdfont_installed,
component_separators = {},
section_separators = {},
extensions = {},
globalstatus = true
},
sections = {
lualine_a = { { 'mode' } },
lualine_b = {
{ 'branch', icons_enabled = true },
{ 'diff' },
{ require('my.functions').lsp_status, padding = 0 },
{ 'diagnostics' }
},
lualine_c = {
{ 'filename', path = 1, newfile_status = true,
cond = not_firenvim },
{ require('my.functions').current_function, padding = 0,
color = 'StatusLineNC' }
},
lualine_x = { { require('my.functions').lsp_sig_status,
color = 'StatusLineNC' }, { 'filetype' } },
lualine_y = { { 'progress' } },
lualine_z = { { 'location' }, { '"🍄"', padding = 0 }
}
},
})
if vim.version().api_level >= 10 then -- >=0.8.0
require('lualine').setup({
inactive_winbar = {
lualine_c = { { 'filename', cond = not_firenvim } },
}
})
end
map('n', '<Leader>B', require('bug-reference').open, 'Open bug under cursor')
local mind = require('mind')
mind.setup({
ui = {
width = 50
}
})
map('n', '<C-F9>', mind.open_main, 'Open main mind')
map('n', '<F33>', mind.open_main, 'Open main mind') -- <C-F9> = <F33>
map('n', '<S-F9>', mind.open_main, 'Open main mind')
map('n', '<F21>', mind.open_project, 'Open project mind') -- <S-F9> = <F21>
require('nvim-surround').setup({})
vim.g.table_mode_map_prefix = '<Leader>T'
require('which-key').register({ ['<Leader>T'] = { name = 'Table mode' } })
require('dressing').setup({
input = {
relative = 'win',
anchor = 'SW',
min_width = { 60, 0.4 },
}
})
require('notify').setup({
on_open = function(win)
vim.api.nvim_win_set_option(win, 'wrap', true) -- does not work
end,
stages = 'static',
})
vim.notify = require('notify')
require('autolist').setup({})