diff --git a/README.md b/README.md index 185280b..d8561d8 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,7 @@ A starter template for [LazyVim](https://github.com/LazyVim/LazyVim). Refer to the [documentation](https://lazyvim.github.io/installation) to get started. + +You will need to pass various commands through the terminal to get started. This is a simple guide to get you started. + +- Command + S: 0x13 diff --git a/lazy-lock.json b/lazy-lock.json index 2aef232..b69ed93 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -16,6 +16,7 @@ "grug-far.nvim": { "branch": "main", "commit": "293f28a7279629076191e6d6cc2397f20e783268" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, + "lazygit.nvim": { "branch": "main", "commit": "b9eae3badab982e71abab96d3ee1d258f0c07961" }, "lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, @@ -37,6 +38,5 @@ "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "ts-comments.nvim": { "branch": "main", "commit": "1bd9d0ba1d8b336c3db50692ffd0955fe1bb9f0c" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, - "window-picker": { "branch": "main", "commit": "5902827d0e338890a22849e2f18dc80d1cc1a8db" } + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 040d509..6b6168c 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -4,8 +4,6 @@ vim.keymap.set("n", "", ":w", { desc = "Save file", silent = true }) vim.keymap.set("i", "", ":wa", { desc = "Save file", silent = true }) vim.g.neovide_input_macos_option_key_is_meta = "only_left" - -vim.api.nvim_echo({ { "Terminal toggle binding loaded!", "Normal" } }, true, {}) -- Terminal keybindings with Ctrl+` vim.keymap.set({ "n", "t" }, "", function() local term_bufnrs = {} diff --git a/lua/plugins/lazygit.lua b/lua/plugins/lazygit.lua new file mode 100644 index 0000000..5afea02 --- /dev/null +++ b/lua/plugins/lazygit.lua @@ -0,0 +1,10 @@ +return { + "kdheepak/lazygit.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, + cmd = "LazyGit", + keys = { + { "gg", "LazyGit", desc = "Open LazyGit" }, + }, +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..cf5f303 --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,178 @@ +return { + "neovim/nvim-lspconfig", + opts = { + -- make sure mason installs the server + servers = { + --- @deprecated -- tsserver renamed to ts_ls but not yet released, so keep this for now + --- the proper approach is to check the nvim-lspconfig release version when it's released to determine the server name dynamically + tsserver = { + enabled = false, + }, + ts_ls = { + enabled = false, + }, + vtsls = { + -- explicitly add default filetypes, so that we can extend + -- them in related extras + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + settings = { + -- format on save + complete_function_calls = true, + vtsls = { + enableMoveToFileCodeAction = true, + autoUseWorkspaceTsdk = true, + experimental = { + maxInlayHintLength = 30, + completion = { + enableServerSideFuzzyMatch = true, + }, + }, + }, + typescript = { + format = { + organizeImportsOnSave = true, + }, + updateImportsOnFileMove = { enabled = "always" }, + suggest = { + completeFunctionCalls = true, + }, + inlayHints = { + enumMemberValues = { enabled = true }, + functionLikeReturnTypes = { enabled = true }, + parameterNames = { enabled = "literals" }, + parameterTypes = { enabled = true }, + propertyDeclarationTypes = { enabled = true }, + variableTypes = { enabled = false }, + }, + }, + }, + keys = { + { + "gD", + function() + local params = vim.lsp.util.make_position_params() + LazyVim.lsp.execute({ + command = "typescript.goToSourceDefinition", + arguments = { params.textDocument.uri, params.position }, + open = true, + }) + end, + desc = "Goto Source Definition", + }, + { + "gR", + function() + LazyVim.lsp.execute({ + command = "typescript.findAllFileReferences", + arguments = { vim.uri_from_bufnr(0) }, + open = true, + }) + end, + desc = "File References", + }, + { + "co", + LazyVim.lsp.action["source.organizeImports"], + desc = "Organize Imports", + }, + { + "cM", + LazyVim.lsp.action["source.addMissingImports.ts"], + desc = "Add missing imports", + }, + { + "cu", + LazyVim.lsp.action["source.removeUnused.ts"], + desc = "Remove unused imports", + }, + { + "cD", + LazyVim.lsp.action["source.fixAll.ts"], + desc = "Fix all diagnostics", + }, + { + "cV", + function() + LazyVim.lsp.execute({ command = "typescript.selectTypeScriptVersion" }) + end, + desc = "Select TS workspace version", + }, + }, + }, + }, + setup = { + --- @deprecated -- tsserver renamed to ts_ls but not yet released, so keep this for now + --- the proper approach is to check the nvim-lspconfig release version when it's released to determine the server name dynamically + tsserver = function() + -- disable tsserver + return true + end, + ts_ls = function() + -- disable tsserver + return true + end, + vtsls = function(_, opts) + LazyVim.lsp.on_attach(function(client, buffer) + client.commands["_typescript.moveToFileRefactoring"] = function(command, ctx) + ---@type string, string, lsp.Range + local action, uri, range = unpack(command.arguments) + + local function move(newf) + client.request("workspace/executeCommand", { + command = command.command, + arguments = { action, uri, range, newf }, + }) + end + + local fname = vim.uri_to_fname(uri) + client.request("workspace/executeCommand", { + command = "typescript.tsserverRequest", + arguments = { + "getMoveToRefactoringFileSuggestions", + { + file = fname, + startLine = range.start.line + 1, + startOffset = range.start.character + 1, + endLine = range["end"].line + 1, + endOffset = range["end"].character + 1, + }, + }, + }, function(_, result) + ---@type string[] + local files = result.body.files + table.insert(files, 1, "Enter new path...") + vim.ui.select(files, { + prompt = "Select move destination:", + format_item = function(f) + return vim.fn.fnamemodify(f, ":~:.") + end, + }, function(f) + if f and f:find("^Enter new path") then + vim.ui.input({ + prompt = "Enter move destination:", + default = vim.fn.fnamemodify(fname, ":h") .. "/", + completion = "file", + }, function(newf) + return newf and move(newf) + end) + elseif f then + move(f) + end + end) + end) + end + end, "vtsls") + -- copy typescript settings to javascript + opts.settings.javascript = + vim.tbl_deep_extend("force", {}, opts.settings.typescript, opts.settings.javascript or {}) + end, + }, + }, +} diff --git a/lua/plugins/window-picker.lua b/lua/plugins/window-picker.lua deleted file mode 100644 index 7dd5815..0000000 --- a/lua/plugins/window-picker.lua +++ /dev/null @@ -1,45 +0,0 @@ -return { - { - "s1n7ax/nvim-window-picker", - name = "window-picker", - event = "VeryLazy", - version = "v1.*", - config = function() - require("window-picker").setup({ - -- Set your configuration options here - autoselect_one = true, - include_current = false, - filter_rules = { - -- filter using buffer options - bo = { - -- if the file type is one of following, the window will be ignored - filetype = { "neo-tree", "neo-tree-popup", "notify", "lazy" }, - -- if the buffer type is one of following, the window will be ignored - buftype = { "terminal", "quickfix" }, - }, - }, - -- Other options: 'label', 'both' - selection_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - show_prompt = true, - prompt_message = "Pick window: ", - }) - - -- Key mappings to select windows - vim.keymap.set("n", "wp", function() - local picked_window_id = require("window-picker").pick_window() or vim.api.nvim_get_current_win() - vim.api.nvim_set_current_win(picked_window_id) - end, { desc = "Pick window" }) - - -- Optional: Add a mapping to swap windows - vim.keymap.set("n", "ws", function() - local picked_window_id = require("window-picker").pick_window() or vim.api.nvim_get_current_win() - local current_window_id = vim.api.nvim_get_current_win() - local current_buffer = vim.api.nvim_get_current_buf() - local picked_buffer = vim.api.nvim_win_get_buf(picked_window_id) - - vim.api.nvim_win_set_buf(current_window_id, picked_buffer) - vim.api.nvim_win_set_buf(picked_window_id, current_buffer) - end, { desc = "Swap windows" }) - end, - }, -}