diff --git a/init.lua b/init.lua index c12ea4a6..b8a5280e 100644 --- a/init.lua +++ b/init.lua @@ -112,7 +112,7 @@ vim.o.confirm = true vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +-- vim.keymap.set('n', 'dq', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) -- 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 @@ -137,6 +137,9 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +-- NOTE These are Custom +vim.keymap.set('n', 'x', ':q', { desc = 'Kill buffer' }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -278,7 +281,9 @@ require('lazy').setup({ spec = { { 'f', group = '[F]ind' }, { 't', group = '[T]oggle' }, - { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + { 'd', group = '[D]ebug' }, + { 'g', group = 'Git', mode = { 'n', 'v' } }, + { 'q', group = 'Quickfix' }, }, }, }, @@ -333,12 +338,12 @@ require('lazy').setup({ -- Telescope picker. This is really useful to discover what Telescope can -- do as well as how to actually do it! + local actions = require 'telescope.actions' -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` - -- defaults = { layout_strategy = 'horizontal', layout_config = { @@ -346,11 +351,25 @@ require('lazy').setup({ height = 0.9, }, preview_width = 0.6, + + path_display = { 'truncate' }, mappings = { - i = { [''] = 'to_fuzzy_refine' }, + n = { + [''] = actions.add_selected_to_qflist + actions.open_qflist, + }, + i = { + [''] = 'to_fuzzy_refine', + [''] = actions.cycle_history_next, + [''] = actions.cycle_history_prev, + [''] = actions.add_selected_to_qflist + actions.open_qflist, + }, + }, + }, + pickers = { + find_files = { + find_command = { 'rg', '--files', '--hidden', '--glob', '!**/.git/*' }, }, }, - -- pickers = {} extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -619,7 +638,11 @@ 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 = { + capabilities = capabilities, + }, + vue_ls = {}, + eslint = {}, -- lua_ls = { @@ -706,13 +729,30 @@ 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 }, - typescript = { 'prettierd' }, - typescriptreact = { 'prettierd' }, + svelte = { { 'prettierd', 'prettier', stop_after_first = true } }, + astro = { { 'prettierd', 'prettier', stop_after_first = true } }, + javascript = { { 'prettierd', 'prettier', stop_after_first = true } }, + typescript = { { 'prettierd', 'prettier', stop_after_first = true } }, + javascriptreact = { { 'prettierd', 'prettier', stop_after_first = true } }, + typescriptreact = { { 'prettierd', 'prettier', stop_after_first = true } }, + json = { { 'prettierd', 'prettier', stop_after_first = true } }, + graphql = { { 'prettierd', 'prettier', stop_after_first = true } }, + java = { 'google-java-format' }, + kotlin = { 'ktlint' }, + ruby = { 'standardrb' }, + markdown = { { 'prettierd', 'prettier', stop_after_first = true } }, + erb = { 'htmlbeautifier' }, + html = { 'htmlbeautifier' }, + bash = { 'beautysh' }, + proto = { 'buf' }, + rust = { 'rustfmt' }, + yaml = { 'yamlfix' }, + toml = { 'taplo' }, + css = { { 'prettierd', 'prettier', stop_after_first = true } }, + scss = { { 'prettierd', 'prettier', stop_after_first = true } }, + sh = { 'shellcheck' }, + go = { 'gofmt' }, + xml = { 'xmllint' }, }, }, }, @@ -911,22 +951,10 @@ require('lazy').setup({ -- init.lua. If you want these files, they are in the repository, so you can just download them and -- place them in the correct locations. - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart - -- - -- Here are some example plugins that I've included in the Kickstart repository. - -- Uncomment any of the lines below to enable them (you will need to restart nvim). - -- - require 'kickstart.plugins.debug', - require 'kickstart.plugins.indent_line', - require 'kickstart.plugins.lint', - require 'kickstart.plugins.autopairs', - require 'kickstart.plugins.neo-tree', - require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. + { import = 'kickstart.plugins' }, { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` diff --git a/lazy-lock.json b/lazy-lock.json index 1e6efa49..94516133 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,29 +1,31 @@ { "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "blink.cmp": { "branch": "main", "commit": "9bcb14b43852a6f2bfd5ac9ef29cb5cf09b1b39b" }, - "conform.nvim": { "branch": "master", "commit": "4c9003aab62879612c50136649baa1b8ed36cfa1" }, + "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, - "gitsigns.nvim": { "branch": "main", "commit": "588264bee92993df92535b6742576f5655c91b1c" }, + "gitsigns.nvim": { "branch": "main", "commit": "c80e0b4bfc411d5740a47adc8775fd1070f2028b" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, "lazygit.nvim": { "branch": "main", "commit": "4839ab642962cc76bb1bf278427dc4c59be15072" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, + "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "73e0143385d8a2185944b42ed44d728b94ee19a3" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "mini.nvim": { "branch": "main", "commit": "48f48e4b3f317e9da34ee7a01958b4c5018e2d34" }, - "neo-tree.nvim": { "branch": "main", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-dap": { "branch": "master", "commit": "14fe46ae16eb272629144a93f7738f5279665a4f" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-dap": { "branch": "master", "commit": "1c75a797b4017fec6491f509cf196c8c8833f26f" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "1cb30b1bafe5a63a5c6ac20dc39f83487df38855" }, + "nvim-lspconfig": { "branch": "master", "commit": "1ddc1a2e692b120cda6d33c890461e49cb85d6bf" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, + "nvim-tree.lua": { "branch": "master", "commit": "6b5b36659688767fb9f133bb83024ab1466fe5cd" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, @@ -34,5 +36,6 @@ "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "d52d70780ca6497ed28ad1b11bb1e981f666f62a" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index 18673e62..00000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - require 'kickstart.plugins.debug', - require 'kickstart.plugins.indent_line', - require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - require 'kickstart.plugins.neo-tree', - require 'kickstart.plugins.gitsigns', -} diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua index 254236bc..dc1a44a2 100644 --- a/lua/custom/plugins/lazygit.lua +++ b/lua/custom/plugins/lazygit.lua @@ -15,6 +15,6 @@ return { -- setting the keybinding for LazyGit with 'keys' is recommended in -- order to load the plugin when the command is run for the first time keys = { - { 'lg', 'LazyGit', desc = 'LazyGit' }, + { 'gg', 'LazyGit', desc = 'LazyGit' }, }, } diff --git a/lua/custom/plugins/tree.lua b/lua/custom/plugins/tree.lua new file mode 100644 index 00000000..bfbf3a8a --- /dev/null +++ b/lua/custom/plugins/tree.lua @@ -0,0 +1,89 @@ +return { + 'nvim-tree/nvim-tree.lua', + version = '*', + lazy = false, + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = function() + local function custom_attach(bufnr) + local api = require 'nvim-tree.api' + + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + local function edit_or_open() + local node = api.tree.get_node_under_cursor() + + if node.nodes ~= nil then + -- expand or collapse folder + api.node.open.edit() + else + -- open file + api.node.open.edit() + -- Close the tree if file was opened + api.tree.close() + end + end + + -- open as vsplit on current node + local function vsplit_preview() + local node = api.tree.get_node_under_cursor() + + if node.nodes ~= nil then + -- expand or collapse folder + api.node.open.edit() + else + -- open file as vsplit + api.node.open.vertical() + end + + -- Finally refocus on tree if it was lost + api.tree.focus() + end + + -- default mappings + api.config.mappings.default_on_attach(bufnr) + + -- custom mappings + vim.keymap.set('n', '', api.tree.change_root_to_parent, opts 'Up') + vim.keymap.set('n', '?', api.tree.toggle_help, opts 'Help') + -- + -- global + vim.api.nvim_set_keymap('n', '', ':NvimTreeToggle', { silent = true, noremap = true }) + + -- on_attach + vim.keymap.set('n', 'l', edit_or_open, opts 'Edit Or Open') + vim.keymap.set('n', 'L', vsplit_preview, opts 'Vsplit Preview') + vim.keymap.set('n', 'h', api.tree.close, opts 'Close') + vim.keymap.set('n', 'H', api.tree.collapse_all, opts 'Collapse All') + end + + require('nvim-tree').setup { + on_attach = custom_attach, + sort = { + sorter = 'case_sensitive', + }, + view = { + width = 30, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, + } + end, +} +-- return { +-- 'nvim-tree/nvim-tree.lua', +-- version = '*', +-- lazy = false, +-- dependencies = { +-- 'nvim-tree/nvim-web-devicons', +-- }, +-- config = function() +-- require('nvim-tree').setup {} +-- end, +-- } diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 00000000..a750f808 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,33 @@ +return { + 'folke/trouble.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + cmd = { 'Trouble' }, + opts = {}, -- Use default options + keys = { + { + 'qx', + 'Trouble diagnostics toggle', + desc = 'Toggle Diagnostics', + }, + { + 'qd', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Toggle Document Diagnostics', + }, + { + 'qq', + 'Trouble quickfix toggle', + desc = 'Toggle Quickfix List', + }, + { + 'ql', + 'Trouble loclist toggle', + desc = 'Toggle Location List', + }, + { + 'qr', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'Toggle LSP References', + }, + }, +} diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua index 386d392e..2106204c 100644 --- a/lua/kickstart/plugins/autopairs.lua +++ b/lua/kickstart/plugins/autopairs.lua @@ -1,6 +1,3 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - return { 'windwp/nvim-autopairs', event = 'InsertEnter', diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 8e332bf2..fccec92b 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -55,14 +55,14 @@ return { desc = 'Debug: Step Out', }, { - 'b', + 'db', function() require('dap').toggle_breakpoint() end, desc = 'Debug: Toggle Breakpoint', }, { - 'B', + 'dB', function() require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua index cbbd22d2..8426f8ad 100644 --- a/lua/kickstart/plugins/gitsigns.lua +++ b/lua/kickstart/plugins/gitsigns.lua @@ -41,20 +41,20 @@ return { gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } end, { desc = 'git [r]eset hunk' }) -- normal mode - map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) - map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) - map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) - map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) - map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) - map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) - map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) - map('n', 'hD', function() + map('n', 'gs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) + map('n', 'gr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) + map('n', 'gS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) + map('n', 'gu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) + map('n', 'gR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) + map('n', 'gp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) + map('n', 'gb', gitsigns.blame_line, { desc = 'git [b]lame line' }) + map('n', 'gd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) + map('n', 'gD', function() gitsigns.diffthis '@' end, { desc = 'git [D]iff against last commit' }) -- Toggles - map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) + map('n', 'tgb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) + map('n', 'tgD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) end, }, }, diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 776aa425..37e7c987 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -14,7 +14,9 @@ return { javascript = { 'eslint' }, javascripttreact = { 'eslint' }, typescript = { 'eslint' }, - typescriptreact = { 'eslint' }, + svelte = { 'eslint_d' }, + kotlin = { 'ktlint' }, + terraform = { 'tflint' }, } -- To allow other plugins to add linters to require('lint').linters_by_ft, @@ -38,15 +40,18 @@ return { -- } -- -- You can disable the default linters by setting their filetypes to nil: - lint.linters_by_ft['markdown'] = nil - lint.linters_by_ft['dockerfile'] = nil - lint.linters_by_ft['json'] = nil - lint.linters_by_ft['rst'] = nil - lint.linters_by_ft['text'] = nil - lint.linters_by_ft['javascript'] = nil - lint.linters_by_ft['javascripttreact'] = nil - lint.linters_by_ft['typescript'] = nil - lint.linters_by_ft['typescriptreact'] = nil + lint.linters_by_ft['markdown'] = nil + lint.linters_by_ft['dockerfile'] = nil + lint.linters_by_ft['json'] = nil + lint.linters_by_ft['rst'] = nil + lint.linters_by_ft['text'] = nil + lint.linters_by_ft['javascript'] = nil + lint.linters_by_ft['javascripttreact'] = nil + lint.linters_by_ft['typescript'] = nil + lint.linters_by_ft['typescriptreact'] = nil + lint.linters_by_ft['svelte'] = nil + lint.linters_by_ft['kotlin'] = nil + lint.linters_by_ft['terraform'] = nil -- Create autocommand which carries out the actual linting -- on the specified events. diff --git a/lua/kickstart/plugins/lualine.lua b/lua/kickstart/plugins/lualine.lua new file mode 100644 index 00000000..9446f8e7 --- /dev/null +++ b/lua/kickstart/plugins/lualine.lua @@ -0,0 +1,45 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup { + options = { + theme = 'tokyonight', + component_separators = '', + section_separators = { left = '', right = '' }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } }, + lualine_b = { 'branch', 'diagnostics' }, + lualine_c = { { 'filename', path = 1 } }, + + lualine_x = {}, + lualine_y = { 'filetype', 'progress' }, + lualine_z = { + { 'location', separator = { right = '' }, left_padding = 2 }, + }, + }, + inactive_sections = { + lualine_a = { 'filename' }, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = { 'location' }, + }, + tabline = {}, + extensions = {}, + } + end, +} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua deleted file mode 100644 index c7067891..00000000 --- a/lua/kickstart/plugins/neo-tree.lua +++ /dev/null @@ -1,25 +0,0 @@ --- Neo-tree is a Neovim plugin to browse the file system --- https://github.com/nvim-neo-tree/neo-tree.nvim - -return { - 'nvim-neo-tree/neo-tree.nvim', - version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended - 'MunifTanjim/nui.nvim', - }, - lazy = false, - keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, - }, - opts = { - filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - }, - }, - }, - }, -}