diff --git a/README.md b/README.md index 2232c655..c9eba05c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ If you are experiencing issues, please make sure you have the latest versions. External Requirements: - Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) -- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) +- [ripgrep](https://github.com/BurntSushi/ripgrep#installation), + [fd-find](https://github.com/sharkdp/fd#installation) - Clipboard tool (xclip/xsel/win32yank or other depending on the platform) - A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons - if you have it set `vim.g.have_nerd_font` in `init.lua` to true diff --git a/lua/keymaps.lua b/lua/keymaps.lua index b281c815..67599529 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -21,6 +21,12 @@ vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = 'Open netrw' }) -- open n -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) + -- TIP: Disable arrow keys in normal mode, i don use them +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('n', '', 'echo "Use j to move!!"') + -- Keybinds to make split navigation easier. -- NOTE: Use CTRL+ to switch between windows -- See `:help wincmd` for a list of all window commands @@ -29,6 +35,12 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes +vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) +vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) +vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) +vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) + -- copy pasting vim.keymap.set('n', 'Y', 'y$', { desc = 'Yank till the end of the line' }) vim.keymap.set('n', 'J', 'mzJ`z', { desc = 'Marks the point (mz), joins the lines (J) and gets back to the marked place (`z)' }) @@ -58,16 +70,12 @@ vim.keymap.set('n', 'k', ':m .-2==', { desc = 'Move line down in in -- Window management vim.keymap.set('n', '', '', { desc = 'Close window with ctrl+c' }) --- Markdown preview haven't setup this plugin --- vim.keymap.set('n', 'mp', ':Glow', { desc = 'Remap glow to show markdown preview' }) --- vim.keymap.set('n', 'mq', ':Glow!', { desc = 'Remap glow to close markdown preview' }) - -- Save file vim.keymap.set({ 'i', 'v', 'n', 's' }, '', 'w', { desc = 'Save file' }) -- Function and remap to toggle relative numbers. -vim.keymap.set('n', 'nr', function() vim.opt.nu = false vim.opt.relativenumber = false end, { desc = 'Disable number and relative number' }) -vim.keymap.set('n', 'rn', function() vim.opt.nu = true vim.opt.relativenumber = true end, { desc = 'Enable number and relative number' }) +vim.keymap.set('n', 'nr', function() vim.o.nu = false vim.opt.relativenumber = false end, { desc = 'Disable number and relative number' }) +vim.keymap.set('n', 'rn', function() vim.o.nu = true vim.opt.relativenumber = true end, { desc = 'Enable number and relative number' }) -- Clean up vim.keymap.set('n', 'dw', ':%s/\\s\\+$//e', { desc = 'Clean trailing whitespace in the document' }) @@ -75,16 +83,20 @@ vim.keymap.set('n', 'dn', ':%s/\\n\\+\\%$//e', { desc = 'Clean trail vim.keymap.set('n', 'ds', ':%s/\\^\\[\\+\\%$//e', { desc = 'Clean trailing escape sequences in the document' }) -- Code runner keymaps -vim.keymap.set('n', 'rr', ':RunCode', { noremap = true, silent = false }) -vim.keymap.set('n', 'rf', ':RunFile', { noremap = true, silent = false }) -vim.keymap.set('n', 'rft', ':RunFile tab', { noremap = true, silent = false }) -vim.keymap.set('n', 'rp', ':RunProject', { noremap = true, silent = false }) -vim.keymap.set('n', 'rc', ':RunClose', { noremap = true, silent = false }) -vim.keymap.set('n', 'crf', ':CRFiletype', { noremap = true, silent = false }) -vim.keymap.set('n', 'crp', ':CRProjects', { noremap = true, silent = false }) +vim.keymap.set('n', 'rr', ':RunCode', { noremap = true, silent = false, desc = 'Run code based on file type.' }) +vim.keymap.set('n', 'rf', ':RunFile', { noremap = true, silent = false, desc = 'Run code in current file.' }) +vim.keymap.set('n', 'rft', ':RunFile tab', { noremap = true, silent = false, desc = 'Run code in current file on a tab.' }) +vim.keymap.set('n', 'rp', ':RunProject', { noremap = true, silent = false, desc = 'Run code in project.' }) +vim.keymap.set('n', 'rc', ':RunClose', { noremap = true, silent = false, desc = 'Close runner.' }) +vim.keymap.set('n', 'crf', ':CRFiletype', { noremap = true, silent = false, desc = 'Open json with supported files.' }) +vim.keymap.set('n', 'crp', ':CRProjects', { noremap = true, silent = false, desc = 'Open json with list of projects.' }) -- Testing remaps and functions -- better indenting -- vim.keymap.set('v', '<', '', '>gv') + +-- Markdown preview haven't setup this plugin +-- vim.keymap.set('n', 'mp', ':Glow', { desc = 'Remap glow to show markdown preview' }) +-- vim.keymap.set('n', 'mq', ':Glow!', { desc = 'Remap glow to close markdown preview' }) diff --git a/lua/lazy-config.lua b/lua/lazy-config.lua index 4b74bec3..69f34900 100644 --- a/lua/lazy-config.lua +++ b/lua/lazy-config.lua @@ -11,7 +11,7 @@ require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). -- Plugins with default values - 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically 'numToStr/Comment.nvim', -- "gc" to comment visual regions/lines 'github/copilot.vim', -- Copilot -- keeping comments for annotation @@ -39,9 +39,8 @@ require('lazy').setup({ -- which loads which-key before all the UI elements are loaded. Events can be -- normal autocommands events (`:help autocmd-events`). -- - -- Then, because we use the `config` key, the configuration only runs - -- after the plugin has been loaded: - -- config = function() ... end + -- Then, because we use the `opts` key (recommended), the configuration runs + -- after the plugin has been loaded as `require(MODULE).setup(opts)`. -- NOTE: Plugins can specify dependencies. -- diff --git a/lua/lazy-install.lua b/lua/lazy-install.lua index b7bf7a83..ddc977b3 100644 --- a/lua/lazy-install.lua +++ b/lua/lazy-install.lua @@ -8,4 +8,4 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then error('Error cloning lazy.nvim:\n' .. out) end end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) +vim.o.rtp:prepend(lazypath) diff --git a/lua/options.lua b/lua/options.lua index fd4d3c89..420f36e2 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,79 +1,79 @@ --- [[ Options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` +-- [[ oions ]] +-- See `:help vim.o` +-- NOTE: You can change these oions as you wish! +-- For more oions, you can see `:help option-list` -- Set numbers and relativenumber -vim.opt.number = true -vim.opt.relativenumber = true +vim.o.number = true +vim.o.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' +vim.o.mouse = 'a' -- Don't show the mode, since it's already in the status line -vim.opt.showmode = false +vim.o.showmode = false -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.schedule(function() - vim.opt.clipboard = 'unnamedplus' -end) +-- vim.schedule(function() +-- vim.o.clipboard = 'unnamedplus' +-- end) --- Set indent --- vim.opt.tabstop = 4 --- vim.opt.softtabstop = 4 --- vim.opt.shiftwidth = 4 -vim.opt.wrap = true -vim.opt.breakindent = true -- keeps text indented after wrap line -vim.opt.expandtab = true -vim.opt.smartindent = true +-- Set indent currently managed by a plugin. +-- vim.o.tabstop = 4 +-- vim.o.softtabstop = 4 +-- vim.o.shiftwidth = 4 +vim.o.wrap = true -- wrap text after textwidth is reached +vim.o.breakindent = true -- keeps text indented after wrap line +vim.o.expandtab = true -- put the amount of spaces each time tab is used +vim.o.smartindent = true -- autodetect indent when starting a newline -- Save undo history and specify path to it. -vim.opt.undofile = true -vim.opt.undodir = os.getenv 'HOME' .. '/.nvim/undodir' +vim.o.undofile = true +vim.o.undodir = os.getenv 'HOME' .. '/.nvim/undodir' -- Don't create swap or backup, we have undo for it -vim.opt.swapfile = false -vim.opt.backup = false +vim.o.swapfile = false +vim.o.backup = false -- Set highlight and navigation -vim.opt.hlsearch = true -- Highlight partial search -vim.opt.incsearch = true -- Incremental search to highlight partial matches +vim.o.hlsearch = true -- Highlight partial search +vim.o.incsearch = true -- Incremental search to highlight partial matches -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.opt.ignorecase = true -vim.opt.smartcase = true -vim.opt.signcolumn = 'yes' -- Keep signcolumn on by default -vim.opt.inccommand = 'split' -- Preview substitutions live, as you type! +vim.o.ignorecase = true +vim.o.smartcase = true +vim.o.signcolumn = 'yes' -- Keep signcolumn on by default +vim.o.inccommand = 'split' -- Preview substitutions live, as you type! -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 20 +vim.o.scrolloff = 20 -- Decrease update time -vim.opt.updatetime = 250 +vim.o.updatetime = 250 -- Decrease mapped sequence wait time -- Displays which-key popup sooner -vim.opt.timeoutlen = 300 +vim.o.timeoutlen = 300 -- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true +vim.o.splitright = true +vim.o.splitbelow = true -- Sets how neovim will display certain whitespace characters in the editor. -- See `:help 'list'` -- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.o.list = true +vim.o.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Show which line your cursor is on -vim.opt.cursorline = true +vim.o.cursorline = true -- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), -- instead raise a dialog asking if you wish to save the current file(s) -- See `:help 'confirm'` -vim.opt.confirm = true +vim.o.confirm = true -- set netrw config vim.g.netrw_banner = 0 -- Remove banner at the top diff --git a/lua/plugins_config/conform.lua b/lua/plugins_config/conform.lua index 50a9c88b..c0684968 100644 --- a/lua/plugins_config/conform.lua +++ b/lua/plugins_config/conform.lua @@ -38,7 +38,12 @@ return { -- Autoformat rust = { 'rustfmt' }, toml = { 'taplo' }, jinja2 = { 'djlint' }, - javascript = { { 'prettierd', 'prettier' } }, + javascript = { 'prettierd', 'prettier' }, + bash = { 'beautysh', 'shellcheck' }, + terraform = { 'terraform_fmt'}, + ansible = { 'ansible-lint' }, + hcl = { 'hcl' }, + markdown = { 'markdownfmt', 'markdownlint' }, -- You can use a sub-list to tell conform to run *until* a formatter -- is found. }, diff --git a/lua/plugins_config/disabled/debug.lua b/lua/plugins_config/disabled/debug.lua index 753cb0ce..8e332bf2 100644 --- a/lua/plugins_config/disabled/debug.lua +++ b/lua/plugins_config/disabled/debug.lua @@ -18,7 +18,7 @@ return { 'nvim-neotest/nvim-nio', -- Installs the debug adapters for you - 'williamboman/mason.nvim', + 'mason-org/mason.nvim', 'jay-babu/mason-nvim-dap.nvim', -- Add your own debuggers here diff --git a/lua/plugins_config/disabled/neo-tree.lua b/lua/plugins_config/disabled/neo-tree.lua index bd442269..c7067891 100644 --- a/lua/plugins_config/disabled/neo-tree.lua +++ b/lua/plugins_config/disabled/neo-tree.lua @@ -9,7 +9,7 @@ return { 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended 'MunifTanjim/nui.nvim', }, - cmd = 'Neotree', + lazy = false, keys = { { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, diff --git a/lua/plugins_config/lint.lua b/lua/plugins_config/lint.lua index 907c6bf3..dec42f09 100644 --- a/lua/plugins_config/lint.lua +++ b/lua/plugins_config/lint.lua @@ -50,7 +50,7 @@ return { -- Only run the linter in buffers that you can modify in order to -- avoid superfluous noise, notably within the handy LSP pop-ups that -- describe the hovered symbol using Markdown. - if vim.opt_local.modifiable:get() then + if vim.bo.modifiable then lint.try_lint() end end, diff --git a/lua/plugins_config/lsp.lua b/lua/plugins_config/lsp.lua index 22893a14..271ea6ea 100644 --- a/lua/plugins_config/lsp.lua +++ b/lua/plugins_config/lsp.lua @@ -13,8 +13,9 @@ return { 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs and related tools to stdpath for Neovim - { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants - 'williamboman/mason-lspconfig.nvim', + -- NOTE: Must be loaded before dependants + { 'mason-org/mason.nvim', opts = {} }, + 'mason-org/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', -- Useful status updates for LSP. @@ -97,13 +98,10 @@ return { -- Similar to document symbols, except searches over your entire project. map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('Rn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') -- Opens a popup that displays documentation about the word under your cursor -- See `:help K` for why this keymap. @@ -212,6 +210,13 @@ return { -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, + ansiblels = {}, + bashls = {}, + gh_actions_ls = {}, + jinja_lsp = {}, + markdown_oxide = {}, + terraform_lsp = {}, + yamlls = {}, gopls = {}, pyright = {}, rust_analyzer = {}, diff --git a/lua/plugins_config/telescope.lua b/lua/plugins_config/telescope.lua index 3899f30c..9c5109e5 100644 --- a/lua/plugins_config/telescope.lua +++ b/lua/plugins_config/telescope.lua @@ -1,7 +1,6 @@ return { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', event = 'VimEnter', - branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', { -- If encountering errors, see telescope-fzf-native README for installation instructions @@ -88,8 +87,8 @@ return { -- Fuzzy Finder (files, lsp, etc) vim.keymap.set('n', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, + winblend = 30, + previewer = true, }) end, { desc = '[/] Fuzzily search in current buffer' }) diff --git a/lua/plugins_config/tree-sitter.lua b/lua/plugins_config/tree-sitter.lua index a98b583f..c62b590d 100644 --- a/lua/plugins_config/tree-sitter.lua +++ b/lua/plugins_config/tree-sitter.lua @@ -4,7 +4,7 @@ return { -- Highlight, edit, and navigate code main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'lua', 'rust', 'toml', 'bash', 'dockerfile', 'go', 'http', 'json', 'make', 'markdown', 'python', 'regex', 'yaml', 'vim', 'vimdoc', 'diff', 'typescript', 'javascript' }, + ensure_installed = { 'lua', 'luadoc', 'rust', 'toml', 'bash', 'dockerfile', 'go', 'json', 'make', 'markdown', 'python', 'regex', 'yaml', 'vim', 'vimdoc', 'diff', 'typescript', 'javascript' }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false,