Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 62 additions & 8 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ vim.g.have_nerd_font = false
-- For more options, you can see `:help option-list`

-- Make line numbers default
vim.opt.number = true
-- vim.opt.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
vim.opt.relativenumber = true

-- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a'
Expand Down Expand Up @@ -189,6 +189,12 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })

-- Map 'jj' to <Esc> in insert mode for quick exit from insert mode
vim.keymap.set('i', 'jj', '<Esc>', { desc = 'Exit insert mode', noremap = true })

vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")

-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`

Expand All @@ -203,6 +209,14 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end,
})

-- Key mapping to open init.lua
vim.api.nvim_set_keymap(
'n', -- mode: normal
'<leader>ev', -- key combination, e.g., \ev if your leader is \
':e ~/.config/nvim/init.lua<CR>', -- command to execute
{ noremap = true, silent = true } -- options
)

-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
Expand Down Expand Up @@ -230,6 +244,30 @@ require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically

'tpope/vim-fugitive',

{
'windwp/nvim-autopairs',
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
local cmp = require 'cmp'
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
},

{
'stevearc/oil.nvim',
opts = {},
dependencies = { { 'echasnovski/mini.icons', opts = {} } },
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
},

-- NOTE: Plugins can also be added by using a table,
-- with the first argument being the link and the following
-- keys can be used to configure plugin behavior/loading/etc.
Expand Down Expand Up @@ -410,6 +448,11 @@ require('lazy').setup({
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')

local function nextError()
vim.diagnostic.goto_next { severity = { vim.diagnostic.severity.ERROR, vim.diagnostic.severity.WARN } }
end
vim.keymap.set('n', ']e', nextError, { desc = 'Next Diagnostic' })

-- See `:help telescope.builtin`
local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
Expand Down Expand Up @@ -668,7 +711,8 @@ require('lazy').setup({
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
ts_ls = {},
eslint = {},
--

lua_ls = {
Expand Down Expand Up @@ -757,11 +801,21 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
javascript = { 'prettierd', 'prettier' },
typescript = { 'prettierd', 'prettier' },
javascriptreact = { 'prettierd', 'prettier' },
typescriptreact = { 'prettierd', 'prettier' },
json = { 'prettierd', 'prettier' },
css = { 'prettierd', 'prettier' },
html = { 'prettierd', 'prettier' },
yaml = { 'prettierd', 'prettier' },
markdown = { 'prettierd', 'prettier' },
},
formatters = {
prettier = {
-- makes it prefer the local project Prettier
prefer_local = 'node_modules/.bin',
},
},
},
},
Expand Down