Skip to content

Commit 1dc6568

Browse files
committed
Improve modules
1 parent 470f43a commit 1dc6568

File tree

7 files changed

+188
-9
lines changed

7 files changed

+188
-9
lines changed

lua/modules/completion.blink.lua

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
return {
2-
{ -- Autocompletion
2+
{ -- Autocompletion with blink.cmp
33
'saghen/blink.cmp',
44
event = 'VimEnter',
55
version = '1.*',
@@ -57,10 +57,30 @@ return {
5757
-- <c-k>: Toggle signature help
5858
--
5959
-- See :h blink-cmp-config-keymap for defining your own keymap
60-
preset = 'default',
60+
preset = "enter", ---@type 'enter' | 'default' | 'super-tab' | 'none'
6161

6262
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
6363
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
64+
['<C-space>'] = false,
65+
-- ['<C-i>'] = { "show", "fallback" },
66+
['<C-h>'] = { "show", "fallback" },
67+
['<C-j>'] = { "select_next", "fallback" },
68+
['<C-n>'] = { "select_next", "fallback" },
69+
['<C-k>'] = { "select_prev", "fallback" },
70+
['<C-p>'] = { "select_prev", "fallback" },
71+
['<CR>'] = { "accept", "fallback" },
72+
["<Tab>"] = {
73+
function(cmp)
74+
if cmp.snippet_active() then
75+
return cmp.accept()
76+
else
77+
return cmp.select_next()
78+
end
79+
end,
80+
"snippet_forward",
81+
"fallback",
82+
},
83+
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
6484
},
6585

6686
appearance = {
@@ -72,14 +92,18 @@ return {
7292
completion = {
7393
-- By default, you may press `<c-space>` to show the documentation.
7494
-- Optionally, set `auto_show = true` to show the documentation after a delay.
75-
documentation = { auto_show = false, auto_show_delay_ms = 500 },
95+
documentation = { auto_show = true, auto_show_delay_ms = 1000 },
7696
},
7797

7898
sources = {
7999
default = { 'lsp', 'path', 'snippets', 'lazydev' },
80100
providers = {
81101
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
82102
},
103+
min_keyword_length = 3
104+
-- min_keyword_length = function()
105+
-- return vim.bo.filetype == 'markdown' and 2 or 0
106+
-- end
83107
},
84108

85109
snippets = { preset = 'luasnip' },
@@ -91,8 +115,9 @@ return {
91115
-- the rust implementation via `'prefer_rust_with_warning'`
92116
--
93117
-- See :h blink-cmp-config-fuzzy for more information
94-
fuzzy = { implementation = 'lua' },
118+
fuzzy = { implementation = 'prefer_rust_with_warning' },
95119

120+
-- opts_extend = { "sources.default" },
96121
-- Shows a signature help window while you type arguments for a function
97122
signature = { enabled = true },
98123
},

lua/modules/explorer.nvimtree.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
return {
2+
-- This is needed for telescope to work fine
3+
{
4+
'nvim-tree/nvim-tree.lua',
5+
version = "*",
6+
lazy = false,
7+
dependencies = {
8+
'nvim-tree/nvim-web-devicons',
9+
},
10+
config = function()
11+
require('nvim-tree').setup({
12+
sort_by = "case_sensitive",
13+
-- auto_close = true, Deprecated
14+
-- actions = {
15+
-- open_file = {
16+
-- quit_on_open = true,
17+
-- },
18+
-- },
19+
view = {
20+
side = "right",
21+
width = 38,
22+
--hide_root_folder = true,
23+
-- mappings = {
24+
-- list = {
25+
-- { key = "u", action = "dir_up" },
26+
-- },
27+
-- },
28+
},
29+
renderer = {
30+
group_empty = true,
31+
},
32+
filters = {
33+
dotfiles = true,
34+
custom = { "^.git$", "^.DS_Store$" },
35+
},
36+
})
37+
end
38+
},
39+
}

lua/modules/finder.telescope.lua

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ return {
99
{ -- Fuzzy Finder (files, lsp, etc)
1010
'nvim-telescope/telescope.nvim',
1111
event = 'VimEnter',
12+
-- branch = '0.1.x',
1213
dependencies = {
1314
'nvim-lua/plenary.nvim',
1415
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
@@ -25,7 +26,6 @@ return {
2526
end,
2627
},
2728
{ 'nvim-telescope/telescope-ui-select.nvim' },
28-
2929
-- Useful for getting pretty icons, but requires a Nerd Font.
3030
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
3131
},
@@ -61,6 +61,17 @@ return {
6161
-- },
6262
-- },
6363
-- pickers = {}
64+
defaults = {
65+
mappings = {
66+
i = {
67+
['<C-u>'] = false,
68+
['<C-d>'] = false,
69+
["<C-j>"] = require('telescope.actions').move_selection_next,
70+
["<C-k>"] = require('telescope.actions').move_selection_previous,
71+
},
72+
},
73+
file_ignore_patterns = { "node_modules" },
74+
},
6475
extensions = {
6576
['ui-select'] = {
6677
require('telescope.themes').get_dropdown(),
@@ -107,6 +118,30 @@ return {
107118
vim.keymap.set('n', '<leader>sn', function()
108119
builtin.find_files { cwd = vim.fn.stdpath 'config' }
109120
end, { desc = '[S]earch [N]eovim files' })
121+
122+
-- Ctrl + P search fuzzy files with Telescope
123+
--vim.keymap.set('n', '<C-p>', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
124+
125+
local function no_other_buffers_open()
126+
local bufnr_list = vim.api.nvim_list_bufs()
127+
for _, bufnr in ipairs(bufnr_list) do
128+
if vim.api.nvim_buf_is_loaded(bufnr) and vim.api.nvim_buf_get_option(bufnr, 'buflisted') then
129+
return false
130+
end
131+
end
132+
return true
133+
end
134+
135+
vim.keymap.set('n', '<C-p>', function()
136+
local telescope = require('telescope.builtin')
137+
-- local tree = require('nvim-tree.view')
138+
local tree = require('nvim-tree.api').tree
139+
if tree.is_visible() and no_other_buffers_open() then
140+
vim.cmd('NvimTreeClose')
141+
end
142+
143+
telescope.find_files()
144+
end, { desc = '[S]earch [F]iles' })
110145
end,
111146
},
112147
}

lua/modules/util.mini.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ return {
3232
return '%2l:%-2v'
3333
end
3434

35+
require('mini.icons').setup()
3536
-- ... and there is more!
3637
-- Check out: https://github.com/echasnovski/mini.nvim
3738
end,

lua/modules/util.treesitter.lua

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ return {
22
{ -- Highlight, edit, and navigate code
33
'nvim-treesitter/nvim-treesitter',
44
build = ':TSUpdate',
5+
dependencies = {
6+
-- Additional text objects via treesitter
7+
'nvim-treesitter/nvim-treesitter-textobjects',
8+
},
59
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
610
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
711
opts = {
8-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
12+
ensure_installed = {
13+
"typescript", "tsx", "lua", "javascript", "vim",
14+
"python", "go", "markdown", "markdown_inline", "bash",
15+
"c", "diff", "html", "luadoc", "vimdoc",
16+
},
917
-- Autoinstall languages that are not installed
1018
auto_install = true,
1119
highlight = {
@@ -15,7 +23,63 @@ return {
1523
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
1624
additional_vim_regex_highlighting = { 'ruby' },
1725
},
18-
indent = { enable = true, disable = { 'ruby' } },
26+
indent = {
27+
enable = true,
28+
disable = { 'python', 'ruby' }
29+
},
30+
incremental_selection = {
31+
enable = true,
32+
keymaps = {
33+
init_selection = '<c-space>',
34+
node_incremental = '<c-space>',
35+
scope_incremental = '<c-s>',
36+
node_decremental = '<c-backspace>',
37+
},
38+
},
39+
textobjects = {
40+
select = {
41+
enable = true,
42+
lookahead = true,
43+
keymaps = {
44+
-- You can use the capture groups defined in textobjects.scm
45+
['aa'] = '@parameter.outer',
46+
['ia'] = '@parameter.inner',
47+
['af'] = '@function.outer',
48+
['if'] = '@function.inner',
49+
['ac'] = '@class.outer',
50+
['ic'] = '@class.inner',
51+
},
52+
},
53+
move = {
54+
enable = true,
55+
set_jumps = true, -- whether to set jumps in the jumplist
56+
goto_next_start = {
57+
[']m'] = '@function.outer',
58+
[']]'] = '@class.outer',
59+
},
60+
goto_next_end = {
61+
[']M'] = '@function.outer',
62+
[']['] = '@class.outer',
63+
},
64+
goto_previous_start = {
65+
['[m'] = '@function.outer',
66+
['[['] = '@class.outer',
67+
},
68+
goto_previous_end = {
69+
['[M'] = '@function.outer',
70+
['[]'] = '@class.outer',
71+
},
72+
},
73+
swap = {
74+
enable = true,
75+
swap_next = {
76+
['<leader>a'] = '@parameter.inner',
77+
},
78+
swap_previous = {
79+
['<leader>A'] = '@parameter.inner',
80+
},
81+
},
82+
},
1983
},
2084
-- There are additional nvim-treesitter modules that you can use to interact
2185
-- with nvim-treesitter. You should go explore a few and see what interests you:
@@ -24,4 +88,4 @@ return {
2488
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
2589
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
2690
},
27-
}
91+
}

lua/modules/utils.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,19 @@ return {
33
{ 'NMAC427/guess-indent.nvim' }, -- Detect tabstop and shiftwidth automatically
44
-- Highlight todo, notes, etc in comments
55
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
6+
-- { 'tpope/vim-fugitive' }
7+
-- { 'tpope/vim-rhubarb', },
8+
9+
-- Plugin for joining/splitting blocks of code
10+
{ 'Wansmer/treesj', dependencies = { 'nvim-treesitter/nvim-treesitter' }, opts = {} },
11+
12+
-- { "kylechui/nvim-surround", event = "VeryLazy", opts = {} },
13+
14+
-- Plugins for writing --
15+
16+
-- { 'reedes/vim-pencil', ft = { 'markdown', 'text' } },
17+
18+
-- { "folke/twilight.nvim", cmd = "Twilight", opts = {} },
19+
20+
-- { 'folke/zen-mode.nvim', cmd = "ZenMode", opts = {} },
621
}

lua/modules/uxui.whichkey.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ return {
1919
opts = {
2020
-- delay between pressing a key and opening which-key (milliseconds)
2121
-- this setting is independent of vim.o.timeoutlen
22-
delay = 0,
22+
delay = 600,
2323
icons = {
2424
-- set icon mappings to true if you have a Nerd Font
2525
mappings = vim.g.have_nerd_font,

0 commit comments

Comments
 (0)