diff --git a/init.lua b/init.lua index f255b6cf..d93fe6e4 100644 --- a/init.lua +++ b/init.lua @@ -83,8 +83,20 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] - --- Set as the leader key +-- Configure netrw to open on the right side +vim.g.netrw_banner = 0 -- Hide the banner +vim.g.netrw_liststyle = 3 -- Use a tree-like view +vim.g.netrw_winsize = 20 -- Set explorer width +vim.g.netrw_altv = 1 -- Open in right vertical split +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.softtabstop = 4 +vim.opt.spell = true -- Enable spell checking +vim.opt.spelllang = 'en' -- Set spell check language to English +vim.opt.foldmethod = 'indent' -- Fold based on indentation +vim.opt.foldlevel = 99 -- Open all folds by default +vim.opt.foldenable = true -- Enable folding-- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) vim.g.mapleader = ' ' @@ -166,6 +178,11 @@ vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +-- Map p to open netrw in a vertical split +vim.keymap.set('n', 'p', function() + vim.cmd 'vertical rightbelow Lexplore 25' -- Open on the right +end, { desc = 'Open file explorer [P]' }) + -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. @@ -594,14 +611,14 @@ require('lazy').setup({ }) -- Change diagnostic symbols in the sign column (gutter) - -- if vim.g.have_nerd_font then - -- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' } - -- local diagnostic_signs = {} - -- for type, icon in pairs(signs) do - -- diagnostic_signs[vim.diagnostic.severity[type]] = icon - -- end - -- vim.diagnostic.config { signs = { text = diagnostic_signs } } - -- end + if vim.g.have_nerd_font then + local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' } + local diagnostic_signs = {} + for type, icon in pairs(signs) do + diagnostic_signs[vim.diagnostic.severity[type]] = icon + end + vim.diagnostic.config { signs = { text = diagnostic_signs } } + end -- LSP servers and clients are able to communicate to each other what features they support. -- By default, Neovim doesn't support everything that is in the LSP specification. @@ -622,7 +639,7 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -643,7 +660,7 @@ require('lazy').setup({ callSnippet = 'Replace', }, -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, + diagnostics = { disable = { 'missing-fields' } }, }, }, }, @@ -682,7 +699,32 @@ require('lazy').setup({ } end, }, - + { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + opts = { + settings = { + tsserver_plugins = { + -- Add support for styled-components, remove if not needed + '@styled/typescript-styled-plugin', + }, + -- Ensures proper Next.js support + tsserver_file_preferences = { + includeInlayParameterNameHints = 'all', + includeInlayVariableTypeHints = true, + }, + tsserver_format_options = { + allowRenameOfImportPath = true, + }, + complete_function_calls = true, -- Auto-complete function arguments + }, + }, + config = function() + require('typescript-tools').setup { + capabilities = require('cmp_nvim_lsp').default_capabilities(), + } + end, + }, { -- Autoformat 'stevearc/conform.nvim', event = { 'BufWritePre' }, @@ -749,7 +791,6 @@ require('lazy').setup({ { 'rafamadriz/friendly-snippets', config = function() - require('luasnip.loaders.from_vscode').lazy_load() require('luasnip.loaders.from_vscode').lazy_load { paths = { vim.fn.stdpath 'config' .. '/snippets' } } end, }, @@ -794,7 +835,7 @@ require('lazy').setup({ -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.confirm { select = true }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines @@ -905,9 +946,9 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'javascript', 'typescript', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -926,6 +967,19 @@ require('lazy').setup({ -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, + { + 'prichrd/netrw.nvim', + opts = {}, + config = function() + require('netrw').setup { + + mappings = { + -- String mappings are executed as vim commands + ['p'] = ':Explore', + }, + } + end, + }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and