Skip to content

Commit dfaacbb

Browse files
committed
feat: enhance Neovim configuration with NetRW disabling, auto number toggling, and code folding setup
1 parent 3338d39 commit dfaacbb

File tree

3 files changed

+104
-4
lines changed

3 files changed

+104
-4
lines changed

init.lua

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,39 @@ I hope you enjoy your Neovim journey,
8484
P.S. You can delete this when you're done too. It's your config now! :)
8585
--]]
8686

87+
-- Disabling NetRW
88+
vim.g.loaded_netrw = 1
89+
vim.g.loaded_netrwPlugin = 1
90+
-- Revealing NeoTree as nvim starts.
91+
vim.api.nvim_create_autocmd('VimEnter', {
92+
pattern = '*',
93+
group = vim.api.nvim_create_augroup('NeotreeOnOpen', { clear = true }),
94+
once = true,
95+
callback = function(_)
96+
if vim.fn.argc() >= 1 then
97+
vim.cmd 'Neotree reveal'
98+
end
99+
end,
100+
})
101+
102+
-- Auto command to toggle absolute and relative numbering.
103+
-- Create an augroup to manage the autocmds
104+
local number_toggle_group = vim.api.nvim_create_augroup('NumberToggle', { clear = true })
105+
106+
-- Autocmd for InsertEnter to disable relative numbers
107+
vim.api.nvim_create_autocmd('InsertEnter', {
108+
pattern = '*',
109+
command = 'set norelativenumber',
110+
group = number_toggle_group,
111+
})
112+
113+
-- Autocmd for InsertLeave to enable relative numbers
114+
vim.api.nvim_create_autocmd('InsertLeave', {
115+
pattern = '*',
116+
command = 'set relativenumber',
117+
group = number_toggle_group,
118+
})
119+
87120
-- Set <space> as the leader key
88121
-- See `:help mapleader`
89122
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
@@ -672,7 +705,7 @@ require('lazy').setup({
672705
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
673706
local servers = {
674707
-- clangd = {},
675-
-- gopls = {},
708+
gopls = {},
676709
-- pyright = {},
677710
-- rust_analyzer = {},
678711
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
@@ -722,6 +755,7 @@ require('lazy').setup({
722755
require('mason-lspconfig').setup {
723756
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
724757
automatic_installation = false,
758+
automatic_enable = false,
725759
handlers = {
726760
function(server_name)
727761
local server = servers[server_name] or {}
@@ -944,7 +978,7 @@ require('lazy').setup({
944978
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
945979
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
946980
opts = {
947-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
981+
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'yaml', 'go' },
948982
-- Autoinstall languages that are not installed
949983
auto_install = true,
950984
highlight = {
@@ -977,8 +1011,26 @@ require('lazy').setup({
9771011
-- require 'kickstart.plugins.indent_line',
9781012
-- require 'kickstart.plugins.lint',
9791013
-- require 'kickstart.plugins.autopairs',
980-
-- require 'kickstart.plugins.neo-tree',
981-
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
1014+
require 'kickstart.plugins.neo-tree',
1015+
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
1016+
require 'kickstart.plugins.nvim-ufo',
1017+
'numToStr/Comment.nvim',
1018+
{
1019+
'github/copilot.vim',
1020+
version = '1.52.0',
1021+
},
1022+
{
1023+
'crusj/bookmarks.nvim',
1024+
keys = {
1025+
{ '<tab><tab>', mode = { 'n' } },
1026+
},
1027+
branch = 'main',
1028+
dependencies = { 'nvim-tree/nvim-web-devicons' },
1029+
config = function()
1030+
require('bookmarks').setup()
1031+
require('telescope').load_extension 'bookmarks'
1032+
end,
1033+
},
9821034

9831035
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
9841036
-- This is the easiest way to modularize your config.

lua/kickstart/plugins/nvim-ufo.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
return {
2+
3+
{
4+
'kevinhwang91/nvim-ufo',
5+
dependencies = {
6+
'kevinhwang91/promise-async',
7+
'nvim-treesitter/nvim-treesitter',
8+
},
9+
config = function()
10+
vim.o.foldcolumn = '1' -- '0' does not show the fold column, higher values increase the width
11+
vim.o.foldlevel = 5 -- Using ufo provider need a large value, feel free to decrease the value
12+
vim.o.foldlevelstart = 99
13+
vim.o.foldenable = true
14+
15+
require('ufo').setup {
16+
provider_selector = function(bufnr, filetype, buftype)
17+
return { 'treesitter', 'indent' }
18+
end,
19+
}
20+
end,
21+
},
22+
}

notes.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Code folding
2+
3+
To see the code fold in left gutter.
4+
set foldcolumn=1
5+
6+
### Creating fold
7+
#### Set coding folding mode
8+
:set foldmethod=manual
9+
10+
#### Creating a manual fold
11+
1. First select a section of lines in visual mode.
12+
2. Press `zf` to create fold, it is `zd` to delete the same fold.
13+
3. `zo` to open fold, `zc` to close fold, `za` to toggle open/close fold
14+
15+
16+
#### Creating indent fold
17+
:set foldmethod=indent
18+
19+
20+
#### Creating expr fold using nvim-treesitter
21+
:set foldlevel=2
22+
:set foldmethod=expr
23+
:set foldexpr=nvim_treesitter#foldexpr()
24+
25+
26+
vim.wo.foldmethod = 'expr'

0 commit comments

Comments
 (0)