Skip to content

Commit b95f034

Browse files
authored
Update Neovim configuration options and keymaps
1 parent 3338d39 commit b95f034

File tree

1 file changed

+86
-36
lines changed

1 file changed

+86
-36
lines changed

init.lua

Lines changed: 86 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ vim.g.mapleader = ' '
9191
vim.g.maplocalleader = ' '
9292

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

9696
-- [[ Setting options ]]
9797
-- See `:help vim.o`
@@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
102102
vim.o.number = true
103103
-- You can also add relative line numbers, to help with jumping.
104104
-- Experiment for yourself to see if you like it!
105-
-- vim.o.relativenumber = true
105+
vim.o.relativenumber = true
106106

107107
-- Enable mouse mode, can be useful for resizing splits for example!
108108
vim.o.mouse = 'a'
@@ -151,12 +151,14 @@ vim.o.splitbelow = true
151151
-- and `:help lua-options-guide`
152152
vim.o.list = true
153153
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
154+
vim.opt['tabstop'] = 2
155+
vim.opt['shiftwidth'] = 2
154156

155157
-- Preview substitutions live, as you type!
156158
vim.o.inccommand = 'split'
157159

158160
-- Show which line your cursor is on
159-
vim.o.cursorline = true
161+
vim.o.cursorline = false
160162

161163
-- Minimal number of screen lines to keep above and below the cursor.
162164
vim.o.scrolloff = 10
@@ -194,16 +196,23 @@ vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }
194196
-- Use CTRL+<hjkl> to switch between windows
195197
--
196198
-- See `:help wincmd` for a list of all window commands
197-
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
198-
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
199-
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
200-
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
199+
200+
vim.keymap.set('n', '<C-d>', '<C-d>zz')
201+
vim.keymap.set('n', '<C-u>', '<C-u>zz')
202+
203+
-- Window navigation with <leader>h/j/k/l
204+
vim.keymap.set('n', '<leader>h', '<C-w>h', { desc = 'Move to left split' })
205+
vim.keymap.set('n', '<leader>j', '<C-w>j', { desc = 'Move to below split' })
206+
vim.keymap.set('n', '<leader>k', '<C-w>k', { desc = 'Move to above split' })
207+
vim.keymap.set('n', '<leader>l', '<C-w>l', { desc = 'Move to right split' })
201208

202209
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
203210
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
204211
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
205212
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
206213
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
214+
--
215+
--
207216

208217
-- [[ Basic Autocommands ]]
209218
-- See `:help lua-guide-autocommands`
@@ -247,15 +256,14 @@ rtp:prepend(lazypath)
247256
-- NOTE: Here is where you install your plugins.
248257
require('lazy').setup({
249258
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
250-
'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically
251-
252-
-- NOTE: Plugins can also be added by using a table,
253-
-- with the first argument being the link and the following
254-
-- keys can be used to configure plugin behavior/loading/etc.
255-
--
256-
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
257-
--
258259

260+
require 'kickstart.plugins.debug',
261+
require 'kickstart.plugins.indent_line',
262+
require 'kickstart.plugins.lint',
263+
require 'kickstart.plugins.autopairs',
264+
require 'kickstart.plugins.neo-tree',
265+
require 'kickstart.plugins.gitsigns',
266+
-- adds gitsigns recommend keymaps
259267
-- Alternatively, use `config = function() ... end` for full control over the configuration.
260268
-- If you prefer to call `setup` explicitly, use:
261269
-- {
@@ -307,7 +315,7 @@ require('lazy').setup({
307315
delay = 0,
308316
icons = {
309317
-- set icon mappings to true if you have a Nerd Font
310-
mappings = vim.g.have_nerd_font,
318+
mappings = false,
311319
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
312320
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
313321
keys = vim.g.have_nerd_font and {} or {
@@ -413,12 +421,28 @@ require('lazy').setup({
413421
-- },
414422
-- },
415423
-- pickers = {}
424+
defaults = {
425+
file_ignore_patterns = { 'node_modules/' },
426+
},
416427
extensions = {
417428
['ui-select'] = {
418429
require('telescope.themes').get_dropdown(),
419430
},
420431
},
421432
}
433+
require('neo-tree').setup {
434+
filesystem = {
435+
filtered_items = {
436+
visible = true,
437+
hide_dotfiles = false,
438+
hide_gitignored = false,
439+
},
440+
},
441+
window = {
442+
width = 30,
443+
},
444+
vim.keymap.set('n', '<leader>e', '<Cmd>Neotree toggle<CR>'),
445+
}
422446

423447
-- Enable Telescope extensions if they are installed
424448
pcall(require('telescope').load_extension, 'fzf')
@@ -428,14 +452,14 @@ require('lazy').setup({
428452
local builtin = require 'telescope.builtin'
429453
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
430454
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
431-
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
455+
-- vim.keymap.set('n', '<leader>k', builtin.find_files, { desc = '[S]earch [F]iles' })
432456
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
433457
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
434458
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
435459
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
436460
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
437461
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
438-
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
462+
vim.keymap.set('n', '<leader><leader>', builtin.find_files, { desc = '[S]earch [F]iles' })
439463

440464
-- Slightly advanced example of overriding default behavior and theme
441465
vim.keymap.set('n', '<leader>/', function()
@@ -553,7 +577,7 @@ require('lazy').setup({
553577
-- Jump to the definition of the word under your cursor.
554578
-- This is where a variable was first declared, or where a function is defined, etc.
555579
-- To jump back, press <C-t>.
556-
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
580+
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
557581

558582
-- WARN: This is not Goto Definition, this is Goto Declaration.
559583
-- For example, in C this would take you to the header.
@@ -681,8 +705,6 @@ require('lazy').setup({
681705
-- https://github.com/pmizio/typescript-tools.nvim
682706
--
683707
-- But for many setups, the LSP (`ts_ls`) will work just fine
684-
-- ts_ls = {},
685-
--
686708

687709
lua_ls = {
688710
-- cmd = { ... },
@@ -716,6 +738,7 @@ require('lazy').setup({
716738
local ensure_installed = vim.tbl_keys(servers or {})
717739
vim.list_extend(ensure_installed, {
718740
'stylua', -- Used to format Lua code
741+
'prettierd',
719742
})
720743
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
721744

@@ -736,6 +759,20 @@ require('lazy').setup({
736759
end,
737760
},
738761

762+
{ -- Typescript / React
763+
'pmizio/typescript-tools.nvim',
764+
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
765+
opts = {
766+
settings = {
767+
tsserver_file_preferences = {
768+
includeCompletionsForModuleExports = true,
769+
includeCompletionsWithInsertText = true,
770+
jsxAttributeCompletionStyle = 'auto',
771+
},
772+
},
773+
},
774+
},
775+
739776
{ -- Autoformat
740777
'stevearc/conform.nvim',
741778
event = { 'BufWritePre' },
@@ -761,18 +798,20 @@ require('lazy').setup({
761798
return nil
762799
else
763800
return {
764-
timeout_ms = 500,
801+
timeout_ms = 1000,
765802
lsp_format = 'fallback',
766803
}
767804
end
768805
end,
769806
formatters_by_ft = {
770807
lua = { 'stylua' },
771-
-- Conform can also run multiple formatters sequentially
772-
-- python = { "isort", "black" },
773-
--
774-
-- You can use 'stop_after_first' to run the first available formatter from the list
775-
-- javascript = { "prettierd", "prettier", stop_after_first = true },
808+
javascript = { 'prettierd' },
809+
javascriptreact = { 'prettierd' },
810+
typescript = { 'prettierd' },
811+
typescriptreact = { 'prettierd' },
812+
css = { 'prettierd' },
813+
html = { 'prettierd' },
814+
json = { 'prettierd' },
776815
},
777816
},
778817
},
@@ -886,6 +925,7 @@ require('lazy').setup({
886925
config = function()
887926
---@diagnostic disable-next-line: missing-fields
888927
require('tokyonight').setup {
928+
transparent = 'true',
889929
styles = {
890930
comments = { italic = false }, -- Disable italics in comments
891931
},
@@ -894,7 +934,7 @@ require('lazy').setup({
894934
-- Load the colorscheme here.
895935
-- Like many other themes, this one has different styles, and you could load
896936
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
897-
vim.cmd.colorscheme 'tokyonight-night'
937+
vim.cmd.colorscheme 'tokyonight-storm'
898938
end,
899939
},
900940

@@ -944,7 +984,23 @@ require('lazy').setup({
944984
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
945985
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
946986
opts = {
947-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
987+
ensure_installed = {
988+
'bash',
989+
'c',
990+
'diff',
991+
'html',
992+
'lua',
993+
'luadoc',
994+
'markdown',
995+
'markdown_inline',
996+
'query',
997+
'vim',
998+
'vimdoc',
999+
'typescript',
1000+
'css',
1001+
'javascript',
1002+
'tsx',
1003+
},
9481004
-- Autoinstall languages that are not installed
9491005
auto_install = true,
9501006
highlight = {
@@ -973,12 +1029,6 @@ require('lazy').setup({
9731029
-- Here are some example plugins that I've included in the Kickstart repository.
9741030
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
9751031
--
976-
-- require 'kickstart.plugins.debug',
977-
-- require 'kickstart.plugins.indent_line',
978-
-- require 'kickstart.plugins.lint',
979-
-- require 'kickstart.plugins.autopairs',
980-
-- require 'kickstart.plugins.neo-tree',
981-
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
9821032

9831033
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
9841034
-- This is the easiest way to modularize your config.
@@ -1013,4 +1063,4 @@ require('lazy').setup({
10131063
})
10141064

10151065
-- The line beneath this is called `modeline`. See `:help modeline`
1016-
-- vim: ts=2 sts=2 sw=2 et
1066+
-- vim ts=2 sts=2 sw=2 et

0 commit comments

Comments
 (0)