Skip to content

Commit

Permalink
refactor: extract related configs into editor
Browse files Browse the repository at this point in the history
  • Loading branch information
BBboy01 committed Nov 28, 2023
1 parent d44674d commit 012ad11
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 292 deletions.
2 changes: 2 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vim.loader.enable()

require('config.options')
require('config.autocmds')
require('config.keymaps')
Expand Down
15 changes: 8 additions & 7 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"dashboard-nvim": { "branch": "master", "commit": "63df28409d940f9cac0a925df09d3dc369db9841" },
"dressing.nvim": { "branch": "master", "commit": "fe3071330a0720ce3695ac915820c8134b22d1b0" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
"git.nvim": { "branch": "main", "commit": "741696687486f25f8b73d9e4c76ab2ede9998f39" },
"friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" },
"gitsigns.nvim": { "branch": "main", "commit": "5fc573f2d2a49aec74dd6dc977e8b137429d1897" },
"indentmini.nvim": { "branch": "main", "commit": "a58129ae424fd6d8e0e2e7f6ce06c0443101e370" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
Expand All @@ -22,11 +21,13 @@
"mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" },
"neodev.nvim": { "branch": "main", "commit": "f972d7e6cd21b691199565cfe3e6487e774a4e8f" },
"neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" },
"none-ls.nvim": { "branch": "main", "commit": "358dd357a753f81412397b8a4cc01a2f41a1b594" },
"noice.nvim": { "branch": "main", "commit": "92433164e2f7118d4122c7674c3834d9511722ba" },
"none-ls.nvim": { "branch": "main", "commit": "fc0f6013ced00fbd61a1ee079427ad445eea0e4b" },
"nui.nvim": { "branch": "main", "commit": "257dccc43b4badc735978f0791d216f7d665b75a" },
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
"nvim-lspconfig": { "branch": "master", "commit": "e4a56adbc51c55964253dce4505cec55c82c1c04" },
"nvim-lspconfig": { "branch": "master", "commit": "daaf00a77805e113acf8ccc02dd8c3403d691683" },
"nvim-tree.lua": { "branch": "master", "commit": "086bf310bd19a7103ee7d761eb59f89f3dd23e21" },
"nvim-treesitter": { "branch": "master", "commit": "b056e4227b1c5d3ecfe96941352364c0c10668df" },
"nvim-treesitter": { "branch": "master", "commit": "ba588ee0cf9df885f3f8698ae671330d82b4bdec" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "dbcd9388e3b119a87c785e10a00d62876077d23d" },
"nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "b8ff464f2afc2000f6c72fa331a8fc090cb46b39" },
Expand All @@ -36,9 +37,9 @@
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "366b0837486f60ae0e7550c15de8ff66d057c4cd" },
"schemastore.nvim": { "branch": "main", "commit": "54a4ea14b70cd3fc9db8217bb4ac9e1f78bfa390" },
"solarized-osaka.nvim": { "branch": "main", "commit": "aeaefec4465deb3ec36f094578e880726c8f8e24" },
"solarized-osaka.nvim": { "branch": "main", "commit": "a823d09b062852194ae15365392bc16274e38fc8" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "d7c453396a043c265bef1227920628e7b811ff30" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "master", "commit": "e4c62dedd760d339bea5b8325c2d918d87476d00" },
"telescope.nvim": { "branch": "master", "commit": "84c5a71d825b6687a55aed6f41e98b92fd8e5454" },
"vim-illuminate": { "branch": "master", "commit": "3bd2ab64b5d63b29e05691e624927e5ebbf0fb86" }
}
2 changes: 0 additions & 2 deletions lua/config/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
vim.loader.enable()

local M = {
icons = {
diagnostics = {
Expand Down
1 change: 1 addition & 0 deletions lua/plugins/colorscheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ return {
config = function(_, opts)
require('solarized-osaka').setup(opts)
vim.cmd('colorscheme solarized-osaka')
vim.cmd.highlight('default link IndentLine Comment')
end,
},
}
231 changes: 231 additions & 0 deletions lua/plugins/editor.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,235 @@
local Util = require('util')

return {
{
'folke/flash.nvim',
event = 'VeryLazy',
---@type Flash.Config
opts = {},
-- stylua: ignore
keys = {
{ " s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
{ "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
},
},

{
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
version = false,
dependencies = {
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
config = function()
Util.on_load('telescope.nvim', function()
require('telescope').load_extension('fzf')
end)
end,
},
'nvim-telescope/telescope-file-browser.nvim',
},
keys = {
{
'<C-p>',
function()
local builtin = require('telescope.builtin')
builtin.find_files({
no_ignore = false,
hidden = true,
})
end,
desc = 'Lists files in your current working directory, respects .gitignore',
},
{
'<Leader>r',
function()
local builtin = require('telescope.builtin')
builtin.live_grep()
end,
desc = 'Search for a string in your current working directory and get results live as you type, respects .gitignore',
},
{
'<Leader>s',
function()
local builtin = require('telescope.builtin')
builtin.current_buffer_fuzzy_find({ fuzzy = false, case_mode = 'ignore_case' })
end,
desc = 'Search from current buffer',
},
{
'<Leader>b',
function()
local builtin = require('telescope.builtin')
builtin.buffers()
end,
desc = 'Lists open buffers',
},
{
'<Leader>t',
function()
local builtin = require('telescope.builtin')
builtin.help_tags()
end,
desc = 'Lists available help tags and opens a new window with the relevant help info on <cr>',
},
{
'\\\\',
function()
local builtin = require('telescope.builtin')
builtin.resume()
end,
desc = 'Resume the previous telescope picker',
},
{
'<Leader>dl',
function()
local builtin = require('telescope.builtin')
builtin.diagnostics({ bufnr = 0 })
end,
desc = 'Lists Diagnostics for all open buffers or a specific buffer',
},
{
'<Leader>?',
function()
local builtin = require('telescope.builtin')
builtin.oldfiles()
end,
desc = 'Lists recently opened files',
},
{
'<leader>S',
function()
local builtin = require('telescope.builtin')
builtin.treesitter()
end,
desc = 'Lists Function names, variables, from Treesitter',
},
{
'sf',
function()
local telescope = require('telescope')

local function telescope_buffer_dir()
return vim.fn.expand('%:p:h')
end

telescope.extensions.file_browser.file_browser({
path = '%:p:h',
cwd = telescope_buffer_dir(),
respect_gitignore = false,
hidden = true,
grouped = true,
previewer = false,
initial_mode = 'normal',
layout_config = { height = 40 },
})
end,
desc = 'Open File Browser with the path of the current buffer',
},
},
config = function(_, opts)
local telescope = require('telescope')
local actions = require('telescope.actions')
local fb_actions = require('telescope').extensions.file_browser.actions

opts.defaults = {
prompt_prefix = '',
selection_caret = '',
-- open files in the first window that is an actual file.
-- use the current window if no other window is available.
get_selection_window = function()
local wins = vim.api.nvim_list_wins()
table.insert(wins, 1, vim.api.nvim_get_current_win())
for _, win in ipairs(wins) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.bo[buf].buftype == '' then
return win
end
end
return 0
end,
wrap_results = true,
layout_strategy = 'horizontal',
layout_config = { prompt_position = 'top' },
sorting_strategy = 'ascending',
winblend = 0,
mappings = {
i = {
['<c-t>'] = open_with_trouble,
['<a-t>'] = open_selected_with_trouble,
['<a-i>'] = find_files_no_ignore,
['<a-h>'] = find_files_with_hidden,
['<C-Down>'] = actions.cycle_history_next,
['<C-Up>'] = actions.cycle_history_prev,
['<C-f>'] = actions.preview_scrolling_down,
['<C-b>'] = actions.preview_scrolling_up,
},
n = {
['q'] = actions.close,
},
},
}
opts.pickers = {
diagnostics = {
theme = 'ivy',
initial_mode = 'normal',
layout_config = {
preview_cutoff = 9999,
},
},
}
opts.extensions = {
file_browser = {
theme = 'dropdown',
-- disables netrw and use telescope-file-browser in its place
hijack_netrw = true,
mappings = {
-- your custom insert mode mappings
['n'] = {
-- your custom normal mode mappings
['N'] = fb_actions.create,
['h'] = fb_actions.goto_parent_dir,
['/'] = function()
vim.cmd('startinsert')
end,
['<C-u>'] = function(prompt_bufnr)
for i = 1, 10 do
actions.move_selection_previous(prompt_bufnr)
end
end,
['<C-d>'] = function(prompt_bufnr)
for i = 1, 10 do
actions.move_selection_next(prompt_bufnr)
end
end,
['<PageUp>'] = actions.preview_scrolling_up,
['<PageDown>'] = actions.preview_scrolling_down,
},
},
},
}
telescope.setup(opts)
require('telescope').load_extension('fzf')
require('telescope').load_extension('file_browser')
end,
},

{
'lewis6991/gitsigns.nvim',
event = 'VeryLazy',
opts = {
signs = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
untracked = { text = '' },
},
},
},

-- Automatically highlights other instances of the word under your cursor.
-- This works with LSP, Treesitter, and regexp matching to find the other
-- instances.
Expand Down
48 changes: 0 additions & 48 deletions lua/plugins/flash.lua

This file was deleted.

30 changes: 0 additions & 30 deletions lua/plugins/git.lua

This file was deleted.

Loading

0 comments on commit 012ad11

Please sign in to comment.