Skip to content

Commit

Permalink
🚧 Change sidebar maping
Browse files Browse the repository at this point in the history
  • Loading branch information
Nguyen-Hoang-Nam committed Apr 4, 2022
1 parent 65d07d0 commit 677face
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 33 deletions.
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,41 +319,41 @@ store in `~/.local/share/nvim/site/pack/*/start/`.

| Plugin | Last updated |
| ----------------------------------------------------------------------------------------------- | ------------ |
| [aerial](https://github.com/stevearc/aerial.nvim) | Mar 23 2022 |
| [aerial](https://github.com/stevearc/aerial.nvim) | Mar 31 2022 |
| [auto-session](https://github.com/rmagatti/auto-session) | Mar 14 2022 |
| [cmp-nvim-lsp](https://github.com/hrsh7th/cmp-nvim-lsp) | Feb 15 2022 |
| [cmp-nvim-lsp-signature-help](https://github.com/hrsh7th/cmp-nvim-lsp-signature-help) | Mar 22 2022 |
| [cmp-nvim-lsp-signature-help](https://github.com/hrsh7th/cmp-nvim-lsp-signature-help) | Mar 29 2022 |
| [cmp-path](https://github.com/hrsh7th/cmp-path) | Feb 3 2022 |
| [cmp_luasnip](https://github.com/saadparwaiz1/cmp_luasnip) | Mar 26 2022 |
| [cmp_luasnip](https://github.com/saadparwaiz1/cmp_luasnip) | Apr 1 2022 |
| [dashboard-nvim](https://github.com/glepnir/dashboard-nvim) | Apr 17 2021 |
| [diffview.nvim](https://github.com/sindrets/diffview.nvim) | Feb 21 2022 |
| [friendly-snippets](https://github.com/rafamadriz/friendly-snippets) | Mar 5 2022 |
| [diffview.nvim](https://github.com/sindrets/diffview.nvim) | Apr 2 2022 |
| [friendly-snippets](https://github.com/rafamadriz/friendly-snippets) | Mar 27 2022 |
| [git-utils.nvim](https://github.com/Nguyen-Hoang-Nam/git-utils.nvim) | |
| [gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim) | Mar 25 2022 |
| [gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim) | Mar 31 2022 |
| [goto-preview](https://github.com/rmagatti/goto-preview) | Dec 25 2021 |
| [indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim) | Mar 25 2022 |
| [LuaSnip](https://github.com/L3MON4D3/LuaSnip) | Mar 26 2022 |
| [nvim-autopair](https://github.com/windwp/nvim-autopairs) | Mar 25 2022 |
| [nvim-bufferline.lua](https://github.com/akinsho/nvim-bufferline.lua) | Mar 21 2022 |
| [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) | Mar 22 2022 |
| [indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim) | Mar 28 2022 |
| [LuaSnip](https://github.com/L3MON4D3/LuaSnip) | Apr 1 2022 |
| [nvim-autopair](https://github.com/windwp/nvim-autopairs) | Apr 2 2022 |
| [nvim-bufferline.lua](https://github.com/akinsho/nvim-bufferline.lua) | Apr 1 2022 |
| [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) | Apr 2 2022 |
| [nvim-colorizer.lua](https://github.com/norcalli/nvim-colorizer.lua) | Apr 20 2020 |
| [nvim-dap](https://github.com/mfussenegger/nvim-dap) | Mar 25 2022 |
| [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui) | Mar 21 2022 |
| [nvim-dap](https://github.com/mfussenegger/nvim-dap) | Apr 2 2022 |
| [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui) | Mar 29 2022 |
| [nvim-dap-virtual-text](https://github.com/theHamsta/nvim-dap-virtual-text) | Feb 19 2021 |
| [nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls) | Feb 24 2022 |
| [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) | Mar 23 2022 |
| [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) | Mar 28 2022 |
| [nvim-mini-file-icons](https://github.com/Nguyen-Hoang-Nam/nvim-mini-file-icons) | |
| [nvim-scrollview](https://github.com/dstein64/nvim-scrollview) | Mar 14 2022 |
| [nvim-toggleterm.lua](https://github.com/akinsho/nvim-toggleterm.lua) | Mar 24 2022 |
| [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) | Mar 21 2022 |
| [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) | Apr 2 2022 |
| [nvim-ts-autotag](https://github.com/windwp/nvim-ts-autotag) | Mar 1 2022 |
| [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring) | Mar 18 2022 |
| [nvim-ts-rainbow](https://github.com/p00f/nvim-ts-rainbow) | Feb 23 2022 |
| [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) | Mar 20 2022 |
| [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) | Mar 30 2022 |
| [rest.nvim](https://github.com/NTBBloodbath/rest.nvim) | Jan 26 2022 |
| [tabout.nvim](https://github.com/abecodes/tabout.nvim) | Mar 19 2021 |
| [telescope-fzf-native.nvim](https://github.com/nvim-telescope/telescope-fzf-native.nvim) | Feb 19 2022 |
| [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) | Mar 26 2022 |
| [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) | Mar 31 2022 |
| [vim-test](https://github.com/vim-test/vim-test) | Mar 26 2022 |
| [vim-ultest](https://github.com/rcarriga/vim-ultest) | Mar 19 2022 |
| [yanil](https://github.com/Nguyen-Hoang-Nam/yanil/tree/customize-ui) | |
Expand Down Expand Up @@ -393,7 +393,6 @@ Check [wiki](https://github.com/Nguyen-Hoang-Nam/nvim-dotfiles-kitty/wiki/Test)
| <Leader>4 | Step out |
| <Leader>9 | Scope information |
| <Leader>a | Code action |
| <Leader>b | Toggle Explorer |
| <Leader>c | Range format |
| <Leader>d | Go to definition |
| <Leader>e | Search Gitmojis |
Expand All @@ -406,14 +405,16 @@ Check [wiki](https://github.com/Nguyen-Hoang-Nam/nvim-dotfiles-kitty/wiki/Test)
| <Leader>r | Rename variable |
| <Leader>s | Save file |
| <Leader>t | Toggle test |
| <Leader>u | Toggle debug sidebar |
| <Leader>u | Search text in project |
| <Leader>v | Run Restful API |
| <Leader>w | Delete current buffer |
| <Leader>x | Toggle symbol sidebar |
| <Leader>z | Preview definition |
| <Leader>/ | Toggle comment |
| <M-b> | Toggle Explorer |
| <M-d> | Toggle debug sidebar |
| <M-t> | Toggle terminal |
| <M-r> | Toggle rest |
| <M-x> | Toggle symbol sidebar |
| jk | Insert to normal |
| gh | Go to left window |
| gj | Go to below window |
Expand Down
5 changes: 1 addition & 4 deletions lua/languages/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ local api = vim.api

local M = {}

-- Credit https://github.com/neovim/nvim-lspconfig#keybindings-and-completion
function M.on_attach(client, bufnr)
api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

local opts = { noremap = true, silent = true }

local function buf_set_keymap(mode, mapping, command)
Expand All @@ -22,7 +19,7 @@ function M.on_attach(client, bufnr)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>')
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>')

vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>x', [[<Cmd>lua require('sidebar').toggle('symbol')<CR>]], {})
buf_set_keymap('n', '<M-x>', [[<Cmd>lua require('sidebar').toggle('symbol')<CR>]])
buf_set_keymap('n', '[x', '<cmd>AerialPrev<CR>')
buf_set_keymap('n', ']x', '<cmd>AerialNext<CR>')
end
Expand Down
7 changes: 4 additions & 3 deletions lua/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ map(
end)
)
map('n', '<Leader>o', '', cmd_option(telescope.buffers))
map('n', '<Leader>p', '', cmd_option(telescope.find_files))
map('n', '<Leader>p', '', cmd_option(utils_core.project_files))
map('n', '<Leader>a', '', cmd_option(telescope.lsp_code_actions))
map('n', '<Leader>u', '', cmd_option(telescope.live_grep))
map(
'n',
'<Leader>e',
Expand Down Expand Up @@ -79,15 +80,15 @@ map('n', '[t', '<Plug>(ultest-prev-fail)', { noremap = false, silent = true })
-- Sidebar
map(
'n',
'<Leader>b',
'<M-b>',
'',
cmd_option(function()
sidebar.toggle('explorer')
end)
)
map(
'n',
'<Leader>u',
'<M-d>',
'',
cmd_option(function()
sidebar.toggle('debug')
Expand Down
72 changes: 66 additions & 6 deletions lua/setup/telescope.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,83 @@
local telescope = require('telescope')
local previewers = require('telescope.previewers')

local new_maker = function(filepath, bufnr, opts)
opts = opts or {}

filepath = vim.fn.expand(filepath)
vim.loop.fs_stat(filepath, function(_, stat)
if not stat then
return
end
if stat.size > 100000 then
return
else
previewers.buffer_previewer_maker(filepath, bufnr, opts)
end
end)
end

telescope.setup({
defaults = {
prompt_prefix = '',

layout_config = {
horizontal = { mirror = false, preview_width = 0.5 },
vertical = { mirror = false },
},

file_ignore_patterns = { 'node_modules/' },
set_env = { COLORTERM = 'truecolor' },
buffer_previewer_maker = new_maker,

-- preview = {
-- mime_hook = function(filepath, bufnr, opts)
-- local get_extension = function(path)
-- local split_path = vim.split(path:lower(), '.', { plain = true })
-- return split_path[#split_path]
-- end

-- local is_image = function(path)
-- local image_extensions = { 'png', 'jpg' } -- Supported image formats
-- local extension = get_extension(path)
-- return vim.tbl_contains(image_extensions, extension)
-- end

-- if is_image(filepath) then
-- local term = vim.api.nvim_open_term(bufnr, {})
-- local function send_output(_, data, _)
-- for _, d in ipairs(data) do
-- vim.api.nvim_chan_send(term, d .. '\r\n')
-- end
-- end

-- vim.fn.jobstart({
-- 'vimg',
-- filepath,
-- 72,
-- vim.o.lines - 32,
-- 20,
-- 20,
-- }, { on_stdout = send_output, stdout_buffered = true })
-- else
-- require('telescope.previewers.utils').set_preview_message(
-- bufnr,
-- opts.winid,
-- 'Binary cannot be previewed'
-- )
-- end
-- end,
-- },
},

-- Remove ./ from fd results
-- Credits https://github.com/nvim-telescope/telescope.nvim/pull/1532
pickers = {
find_files = {
find_command = { 'fd', '--type', 'f', '--strip-cwd-prefix' },
find_command = {
'fd',
'--type',
'f',
'--strip-cwd-prefix',
'--hidden',
'--exclude',
'.git',
},
},
},
})
Expand Down
7 changes: 7 additions & 0 deletions lua/utils/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,11 @@ function M.cover_score()
print(string.sub(score_raw, newline_position))
end

function M.project_files()
local ok = pcall(require('telescope.builtin').git_files)
if not ok then
require('telescope.builtin').find_files()
end
end

return M

0 comments on commit 677face

Please sign in to comment.