Skip to content

Commit e65be93

Browse files
committed
add more plugins
1 parent 38f4744 commit e65be93

File tree

1 file changed

+50
-22
lines changed

1 file changed

+50
-22
lines changed

init.lua

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,19 @@ P.S. You can delete this when you're done too. It's your config now! :)
8989
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
9090
vim.g.mapleader = ' '
9191
vim.g.maplocalleader = ' '
92+
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
93+
pattern = { '*.js', '*.ts', '*.jsx', '*.tsx' },
94+
callback = function()
95+
local file = vim.fn.expand '%:p'
96+
local result = vim.fn.system('npx prettier --write ' .. file)
97+
-- Update the buffer with the newly formatted file content
98+
local formatted = vim.fn.readfile(file)
99+
vim.api.nvim_buf_set_lines(0, 0, -1, false, formatted)
100+
end,
101+
})
92102

93103
-- Set to true if you have a Nerd Font installed and selected in the terminal
94-
vim.g.have_nerd_font = false
104+
vim.g.have_nerd_font = true
95105

96106
-- [[ Setting options ]]
97107
-- See `:help vim.opt`
@@ -102,7 +112,7 @@ vim.g.have_nerd_font = false
102112
vim.opt.number = true
103113
-- You can also add relative line numbers, to help with jumping.
104114
-- Experiment for yourself to see if you like it!
105-
-- vim.opt.relativenumber = true
115+
vim.opt.relativenumber = true
106116

107117
-- Enable mouse mode, can be useful for resizing splits for example!
108118
vim.opt.mouse = 'a'
@@ -170,7 +180,9 @@ vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
170180

171181
-- Diagnostic keymaps
172182
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
173-
183+
-- keep screen centered when moving up or down
184+
vim.keymap.set('n', '<C-d>', '<C-d>zz')
185+
vim.keymap.set('n', '<C-u>', '<C-u>zz')
174186
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
175187
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
176188
-- is not what someone will guess without a bit more experience.
@@ -180,10 +192,10 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
180192
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
181193

182194
-- TIP: Disable arrow keys in normal mode
183-
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
184-
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
185-
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
186-
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
195+
vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
196+
vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
197+
vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
198+
vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
187199

188200
-- Keybinds to make split navigation easier.
189201
-- Use CTRL+<hjkl> to switch between windows
@@ -255,19 +267,35 @@ require('lazy').setup({
255267
--
256268
-- Here is a more advanced example where we pass configuration
257269
-- options to `gitsigns.nvim`.
270+
271+
-- add this to your lua/plugins.lua, lua/plugins/init.lua, or the file you keep your other plugins:
272+
{
273+
'numToStr/Comment.nvim',
274+
opts = {
275+
-- add any options here
276+
},
277+
},
278+
{
279+
'stevearc/oil.nvim',
280+
---@module 'oil'
281+
---@type oil.SetupOpts
282+
opts = {},
283+
-- Optional dependencies
284+
dependencies = { { 'echasnovski/mini.icons', opts = {} } },
285+
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
286+
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
287+
lazy = false,
288+
289+
config = function()
290+
require('oil').setup()
291+
end,
292+
},
293+
258294
--
259295
-- See `:help gitsigns` to understand what the configuration keys do
260296
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
261297
'lewis6991/gitsigns.nvim',
262-
opts = {
263-
signs = {
264-
add = { text = '+' },
265-
change = { text = '~' },
266-
delete = { text = '_' },
267-
topdelete = { text = '' },
268-
changedelete = { text = '~' },
269-
},
270-
},
298+
opts = {},
271299
},
272300

273301
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
@@ -665,15 +693,15 @@ require('lazy').setup({
665693
local servers = {
666694
-- clangd = {},
667695
-- gopls = {},
668-
-- pyright = {},
696+
pyright = {},
669697
-- rust_analyzer = {},
670698
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
671699
--
672700
-- Some languages (like typescript) have entire language plugins that can be useful:
673701
-- https://github.com/pmizio/typescript-tools.nvim
674702
--
675703
-- But for many setups, the LSP (`ts_ls`) will work just fine
676-
-- ts_ls = {},
704+
ts_ls = {},
677705
--
678706

679707
lua_ls = {
@@ -763,10 +791,10 @@ require('lazy').setup({
763791
formatters_by_ft = {
764792
lua = { 'stylua' },
765793
-- Conform can also run multiple formatters sequentially
766-
-- python = { "isort", "black" },
794+
python = { 'isort', 'black' },
767795
--
768796
-- You can use 'stop_after_first' to run the first available formatter from the list
769-
-- javascript = { "prettierd", "prettier", stop_after_first = true },
797+
javascript = { 'prettier', stop_after_first = true },
770798
},
771799
},
772800
},
@@ -987,8 +1015,8 @@ require('lazy').setup({
9871015
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
9881016
--
9891017
-- require 'kickstart.plugins.debug',
990-
-- require 'kickstart.plugins.indent_line',
991-
-- require 'kickstart.plugins.lint',
1018+
require 'kickstart.plugins.indent_line',
1019+
require 'kickstart.plugins.lint',
9921020
-- require 'kickstart.plugins.autopairs',
9931021
-- require 'kickstart.plugins.neo-tree',
9941022
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps

0 commit comments

Comments
 (0)