mirror of
https://github.com/tomru/vim.git
synced 2026-03-03 06:27:18 +01:00
add all previous plugins and config
This commit is contained in:
38
after/plugin/autocmd.lua
Normal file
38
after/plugin/autocmd.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
vim.api.nvim_create_augroup('_general', { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
pattern = '*',
|
||||
group = '_general',
|
||||
callback = function()
|
||||
if vim.api.nvim_buf_line_count(0) < 10000 then
|
||||
vim.opt_local.foldmethod = 'expr'
|
||||
vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||
else
|
||||
vim.opt_local.foldmethod = 'indent'
|
||||
vim.opt_local.list = false
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'qf,help,man,lspinfo,alpha',
|
||||
command = 'nnoremap <silent> <buffer> q :close<CR>',
|
||||
group = '_general',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'qf',
|
||||
command = 'set formatoptions-=cro',
|
||||
group = '_general',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'gitcommit,markdown',
|
||||
command = 'setlocal wrap spell',
|
||||
group = '_general',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('VimResized', {
|
||||
command = 'tabdo wincmd =',
|
||||
group = '_general',
|
||||
})
|
||||
37
after/plugin/bcr.lua
Normal file
37
after/plugin/bcr.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
vim.api.nvim_create_augroup('_bcr', { clear = true })
|
||||
vim.api.nvim_create_autocmd('BufRead,BufNewFile', {
|
||||
pattern = '*/frontend-apps/*/bcr/core/public/*',
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
" set base for requirejs imports
|
||||
setlocal path+=core/public
|
||||
" for mustach templates
|
||||
setlocal isfname-=!
|
||||
setlocal suffixesadd+=.template
|
||||
]])
|
||||
end,
|
||||
group = '_bcr',
|
||||
})
|
||||
vim.api.nvim_create_autocmd('BufRead,BufNewFile', {
|
||||
pattern = '*/frontend-apps/*/bcr/*',
|
||||
callback = function()
|
||||
vim.g.rooter_patterns = { '=bcr' }
|
||||
end,
|
||||
group = '_bcr',
|
||||
})
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
pattern = { '*/frontend-apps/*/bcr/*.[jt]s', '*/frontend-apps/*/bcr/*.[jt]sx', '*/frontend-apps/*/bcr/*.json' },
|
||||
callback = function(opts)
|
||||
local bufnr = opts.buf
|
||||
local client = vim.lsp.get_client_by_id(opts.data.client_id)
|
||||
|
||||
if client.name ~= 'tsserver' then
|
||||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
vim.cmd('EslintFixAll')
|
||||
end, { desc = 'Format current buffer with Eslint' })
|
||||
end,
|
||||
group = '_bcr',
|
||||
})
|
||||
26
after/plugin/defaults.lua
Normal file
26
after/plugin/defaults.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
vim.opt.backup = false
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.writebackup = false
|
||||
|
||||
vim.opt.colorcolumn = { 80, 120 }
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.tabstop = 2
|
||||
|
||||
vim.opt.showmode = false
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.listchars = "tab:» ,extends:›,precedes:‹,nbsp:·,trail:·,eol:↵"
|
||||
|
||||
-- global status line ftw
|
||||
vim.opt.laststatus = 3
|
||||
-- sometimes handy, sometimes not, still evaluating
|
||||
vim.opt.winbar = "%=%m %f"
|
||||
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
|
||||
vim.opt.scrolloff = 4
|
||||
vim.opt.sidescrolloff = 4
|
||||
|
||||
vim.opt.spelllang = { "en_us", "en_gb", "de" }
|
||||
|
||||
vim.opt.foldlevelstart = 99
|
||||
25
after/plugin/keymaps.lua
Normal file
25
after/plugin/keymaps.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
vim.keymap.set('i', 'jk', '<Esc>')
|
||||
vim.keymap.set('t', 'jk', [[<C-\><C-n>]])
|
||||
|
||||
-- quick write
|
||||
vim.keymap.set('n', '<leader>w', vim.cmd.w)
|
||||
|
||||
-- quick source file
|
||||
vim.keymap.set('n', '<leader>x', "<Cmd>source %|echo expand('%') 'sourced'<CR>")
|
||||
|
||||
-- git
|
||||
vim.keymap.set('n', '<leader>gg', '<Cmd>vertical Git<CR>', { desc = '[G]oto [G]it' })
|
||||
|
||||
-- buffers
|
||||
vim.keymap.set('n', '[b', '<Cmd>bprev<CR>', { desc = 'Previous buffer' })
|
||||
vim.keymap.set('n', ']b', '<Cmd>bnext<CR>', { desc = 'Next buffer' })
|
||||
|
||||
-- yank to system clipboard
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>y', [["+y]])
|
||||
vim.keymap.set('n', '<leader>Y', [["+Y]])
|
||||
|
||||
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
|
||||
|
||||
vim.keymap.set('n', 'tsp', function()
|
||||
vim.treesitter.show_tree({ command = 'botright 60vnew', title = 'Treesitter-Tree' })
|
||||
end, { desc = 'Open treesitter tree for current buffer' })
|
||||
142
after/plugin/snips.lua
Normal file
142
after/plugin/snips.lua
Normal file
@@ -0,0 +1,142 @@
|
||||
local has_luasnip, luasnip = pcall(require, 'luasnip')
|
||||
if not has_luasnip then
|
||||
return
|
||||
end
|
||||
|
||||
local ls = luasnip
|
||||
local s = ls.snippet
|
||||
-- local sn = ls.snippet_node
|
||||
-- local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
-- local d = ls.dynamic_node
|
||||
-- local r = ls.restore_node
|
||||
-- local events = require("luasnip.util.events")
|
||||
-- local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require('luasnip.extras')
|
||||
-- local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
-- local p = extras.partial
|
||||
-- local m = extras.match
|
||||
-- local n = extras.nonempty
|
||||
-- local dl = extras.dynamic_lambda
|
||||
local fmt = require('luasnip.extras.fmt').fmt
|
||||
-- local fmta = require("luasnip.extras.fmt").fmta
|
||||
-- local conds = require("luasnip.extras.expand_conditions")
|
||||
-- local postfix = require("luasnip.extras.postfix").postfix
|
||||
-- local types = require("luasnip.util.types")
|
||||
-- local parse = require("luasnip.util.parser").parse_snippet
|
||||
--
|
||||
--
|
||||
|
||||
ls.config.set_config({
|
||||
history = true,
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
})
|
||||
|
||||
local snippets = {
|
||||
all = {
|
||||
s(
|
||||
'timestamp',
|
||||
f(function()
|
||||
return os.date('%Y-%m-%d %H:%M')
|
||||
end)
|
||||
),
|
||||
},
|
||||
lua = {
|
||||
s('hey', c(1, { t('hey ho'), t('hoi') })),
|
||||
s(
|
||||
{ trig = 'prequire', name = 'pcall require' },
|
||||
fmt(
|
||||
[[
|
||||
local has_{}, {} = pcall(require, '{}')
|
||||
if not has_{} then
|
||||
return
|
||||
end
|
||||
{}
|
||||
]],
|
||||
{ rep(1), rep(1), i(1), rep(1), i(0) }
|
||||
)
|
||||
),
|
||||
},
|
||||
javascript = {
|
||||
s(
|
||||
{ trig = 'des', name = 'describe' },
|
||||
fmt(
|
||||
[[
|
||||
describe("{}", () => {{
|
||||
{}
|
||||
}});
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = 'it', name = 'it' },
|
||||
fmt(
|
||||
[[
|
||||
it("{}", () => {{
|
||||
{}
|
||||
}});
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = 'bfe', name = 'beforeEach' },
|
||||
fmt(
|
||||
[[
|
||||
beforeEach(() => {{
|
||||
{}
|
||||
}});
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = 'bf', name = 'beforeX' },
|
||||
fmt(
|
||||
[[
|
||||
before{}(() => {{
|
||||
{}
|
||||
}});
|
||||
]],
|
||||
{ c(1, { t('Each'), t('All') }), i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = 'afe', name = 'afterEach' },
|
||||
fmt(
|
||||
[[
|
||||
afterEach(() => {{
|
||||
{}
|
||||
}});
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = 'egbr', name = 'expect getByRole' },
|
||||
fmt(
|
||||
[[
|
||||
expect(screen.getByRole('{}', {{ name: /{}/i}})).{}
|
||||
]],
|
||||
{ i(1, 'heading'), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = 'tbid', name = 'toBeInDocument()' },
|
||||
fmt(
|
||||
[[
|
||||
toBeInDocument();
|
||||
{}
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
ls.add_snippets(nil, snippets, { key = 'my-snips' })
|
||||
12
after/plugin/witchkey.lua
Normal file
12
after/plugin/witchkey.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local wk = require('which-key')
|
||||
wk.setup({})
|
||||
wk.register({
|
||||
['<leader>'] = {
|
||||
f = { name = '[F]ile' },
|
||||
s = { name = '[S]earch' },
|
||||
t = { name = '[T]est' },
|
||||
w = { name = '[W]orkspace' },
|
||||
g = { name = '[G]it' },
|
||||
l = { name = '[L]SP' },
|
||||
},
|
||||
})
|
||||
15
lua/custom/plugins/filetree.lua
Normal file
15
lua/custom/plugins/filetree.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
vim.cmd [[ let g:neo_tree_remove_legacy_commands = 1 ]]
|
||||
|
||||
return {
|
||||
'nvim-neo-tree/neo-tree.nvim',
|
||||
version = '*',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
|
||||
'MunifTanjim/nui.nvim',
|
||||
},
|
||||
opts = {},
|
||||
keys = {
|
||||
{ '<leader>e', '<cmd>Neotree toggle<cr>', desc = 'NeoTree' },
|
||||
},
|
||||
}
|
||||
38
lua/custom/plugins/formatter.lua
Normal file
38
lua/custom/plugins/formatter.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
return {
|
||||
"mhartington/formatter.nvim",
|
||||
lazy = false,
|
||||
init = function()
|
||||
vim.api.nvim_create_augroup('_formatter', { clear = true });
|
||||
vim.api.nvim_create_autocmd('BufWritePost', {
|
||||
command = 'FormatWrite',
|
||||
group = '_formatter',
|
||||
})
|
||||
end,
|
||||
opts = function()
|
||||
local filetypes = require('formatter.filetypes')
|
||||
return {
|
||||
logging = false,
|
||||
log_level = vim.log.levels.WARN,
|
||||
filetype = {
|
||||
lua = {
|
||||
filetypes.lua.stylua,
|
||||
},
|
||||
javascript = {
|
||||
filetypes.javascript.eslint_d,
|
||||
},
|
||||
javascriptreact = {
|
||||
filetypes.javascript.eslint_d,
|
||||
},
|
||||
json = {
|
||||
filetypes.json.prettierd,
|
||||
},
|
||||
rust = {
|
||||
filetypes.rust.rustfmt,
|
||||
},
|
||||
['*'] = {
|
||||
filetypes.any.remove_trailing_whitespace,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
||||
10
lua/custom/plugins/rooter.lua
Normal file
10
lua/custom/plugins/rooter.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
'notjedi/nvim-rooter.lua',
|
||||
config = function()
|
||||
require('nvim-rooter').setup {
|
||||
rooter_patterns = { '.git', 'Makefile', '=bcr' },
|
||||
trigger_patterns = { '*' },
|
||||
manual = false,
|
||||
}
|
||||
end,
|
||||
}
|
||||
39
lua/custom/plugins/utils.lua
Normal file
39
lua/custom/plugins/utils.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
return {
|
||||
'vim-utils/vim-troll-stopper',
|
||||
{'tpope/vim-abolish', lazy = false },
|
||||
{'tpope/vim-unimpaired', lazy = false },
|
||||
{
|
||||
'rcarriga/nvim-notify',
|
||||
lazy = false,
|
||||
config = function()
|
||||
local notify = require 'notify'
|
||||
notify.setup()
|
||||
vim.notify = notify
|
||||
end,
|
||||
},
|
||||
|
||||
-- rust
|
||||
{ 'simrat39/rust-tools.nvim', opt = {} },
|
||||
{
|
||||
'saecki/crates.nvim',
|
||||
requires = { 'nvim-lua/plenary.nvim' },
|
||||
opt = {}
|
||||
},
|
||||
|
||||
-- testing
|
||||
{
|
||||
'vim-test/vim-test',
|
||||
fn = { "javascript", "typescript", "javascriptreact" },
|
||||
config = function()
|
||||
vim.cmd([[
|
||||
let test#strategy = 'neovim'
|
||||
let test#javascript#jest#file_pattern = '\v(__tests__/.*|(spec|tests?))\.(js|jsx|coffee|ts|tsx)$'
|
||||
]])
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>tn", "<cmd>TestNearest<cr>", desc = "[T]est [N]earest" },
|
||||
{ "<leader>tf", "<cmd>TestFile<cr>", desc = "[T]est [F]ile" },
|
||||
{ "<leader>tt", "<cmd>TestLast<cr>", desc = "[T]est Last" },
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user