diff --git a/README.md b/README.md index a42cf23..a35912c 100755 --- a/README.md +++ b/README.md @@ -1,12 +1,18 @@ # dotfiles -Before doing anything, make sure you know what you're doing! The settings applied by this repository are highly personal and certainly not suitable for everyone. I recommend creating your own set of dotfiles based on this repository. +Before doing anything, make sure you know what you're doing! The settings +applied by this repository are highly personal and certainly not suitable for +everyone. I recommend creating your own set of dotfiles based on this +repository. 1. Install [brew](https://brew.sh). 1. SSH setup. -1. Clone this repo to the hidden `.dotfile` directory in your home directory (`git` comes with brew) - `git clone https://github.com/pawelgrzybek/dotfiles.git ~/.dotfile` +1. Clone this repo to the hidden `.dotfile` directory in your home directory + (`git` comes with brew) - + `git clone https://github.com/pawelgrzybek/dotfiles.git ~/.dotfile` 1. Install brew formulas and casks - `source ~/.dotfiles/setup-brew.sh` -1. Download your fav apps from app store- (Keynote, Ivory, Numbers, Pages, Photomator, Reeder) +1. Download your fav apps from app store- (Keynote, Ivory, Numbers, Pages, + Photomator, Reeder) 1. Setup macOS - `source ~/.dotfiles/setup-macos.sh` 1. Setup symlinks - `source ~/.dotfiles/setup-symlinks.sh` 1. Setup pnpm globals - `source ~/.dotfiles/setup-pnpm.sh` diff --git a/nvim/init.lua b/nvim/init.lua index 00359f7..393ca73 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,3 +1,4 @@ require("pawelgrzybek.options") require("pawelgrzybek.keymaps") +require("pawelgrzybek.autocmds") require("pawelgrzybek.lazy") diff --git a/nvim/lua/pawelgrzybek/autocmds.lua b/nvim/lua/pawelgrzybek/autocmds.lua new file mode 100644 index 0000000..582872b --- /dev/null +++ b/nvim/lua/pawelgrzybek/autocmds.lua @@ -0,0 +1,10 @@ +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) diff --git a/nvim/lua/pawelgrzybek/keymaps.lua b/nvim/lua/pawelgrzybek/keymaps.lua index 0d264d5..3b493f8 100644 --- a/nvim/lua/pawelgrzybek/keymaps.lua +++ b/nvim/lua/pawelgrzybek/keymaps.lua @@ -1,87 +1,32 @@ --- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` -vim.keymap.set("n", "", "nohlsearch") - --- Diagnostic keymaps -vim.keymap.set("n", "q", 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 --- is not what someone will guess without a bit more experience. --- --- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping --- or just use to exit terminal mode -vim.keymap.set("t", "", "", { desc = "Exit terminal mode" }) - -- TIP: Disable arrow keys in normal mode 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. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands -vim.keymap.set("n", "", "", { desc = "Move focus to the left window" }) -vim.keymap.set("n", "", "", { desc = "Move focus to the right window" }) -vim.keymap.set("n", "", "", { desc = "Move focus to the lower window" }) -vim.keymap.set("n", "", "", { desc = "Move focus to the upper window" }) - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd("TextYankPost", { - desc = "Highlight when yanking (copying) text", - group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) - --- before the kickstart adoption --- -- increment/decrement numbers --- vim.keymap.set("n", "+", "", { desc = "Increment number" }) -- increment --- vim.keymap.set("n", "-", "", { desc = "Decrement number" }) -- decrement --- --- -- window management --- vim.keymap.set("n", "sv", "v", { desc = "Split window vertically" }) -- split window vertically --- vim.keymap.set("n", "sh", "s", { desc = "Split window horizontally" }) -- split window horizontally --- vim.keymap.set("n", "se", "=", { desc = "Make splits equal size" }) -- make split windows equal width & height --- vim.keymap.set("n", "sx", "close", { desc = "Close current split" }) -- close current split window --- --- -- tabs management --- vim.keymap.set("n", "to", "tabnew", { desc = "Open new tab" }) -- open new tab --- vim.keymap.set("n", "tx", "tabclose", { desc = "Close current tab" }) -- close current tab --- vim.keymap.set("n", "tn", "tabn", { desc = "Go to next tab" }) -- go to next tab --- vim.keymap.set("n", "tp", "tabp", { desc = "Go to previous tab" }) -- go to previous tab --- vim.keymap.set("n", "tf", "tabnew %", { desc = "Open current buffer in new tab" }) -- move current buffer to new tab --- --- Move/duplicate lines up and down in normal mode +-- Move/duplicate lines up and down (normal mode) vim.keymap.set("n", "", ":m .+1==") vim.keymap.set("n", "", ":m .-2==") vim.keymap.set("n", "", ":t.", { noremap = true, silent = true }) vim.keymap.set("n", "", ":t-1", { noremap = true, silent = true }) --- Move/duplicate lines up and down in insert mode +-- Move/duplicate lines up and down (insert mode) vim.keymap.set("i", "", ":m .+1==gi") vim.keymap.set("i", "", ":m .-2==gi") vim.keymap.set("i", "", ":t.", { noremap = true, silent = true }) vim.keymap.set("i", "", ":t-1", { noremap = true, silent = true }) --- Move/duplicate lines up and down in visual mode +-- Move/duplicate lines up and down (visual mode) vim.keymap.set("v", "", ":m '>+1gv=gv") vim.keymap.set("v", "", ":m '<-2gv=gv") vim.keymap.set("v", "", ":t-1gv", { noremap = true, silent = true }) vim.keymap.set("v", "", ":t'>gv", { noremap = true, silent = true }) --- --- -- copy to system clipboard -vim.keymap.set("n", "y", '"+y') -vim.keymap.set("n", "p", '"+p') -vim.keymap.set("v", "y", '"+y') + +-- Copy/paste to system clipboard vim.keymap.set("v", "y", '"+y') +vim.keymap.set("v", "p", '"+p') --- select all +-- Select all vim.keymap.set("n", "a", "ggVG") -- Diagnostic keymaps diff --git a/nvim/lua/pawelgrzybek/plugins/lsp.lua b/nvim/lua/pawelgrzybek/plugins/lsp.lua index 525e370..0d13f07 100644 --- a/nvim/lua/pawelgrzybek/plugins/lsp.lua +++ b/nvim/lua/pawelgrzybek/plugins/lsp.lua @@ -1,7 +1,7 @@ return { "neovim/nvim-lspconfig", dependencies = { - { "williamboman/mason.nvim", config = true }, + "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", { "j-hui/fidget.nvim", opts = {} }, "hrsh7th/cmp-nvim-lsp", @@ -16,12 +16,6 @@ return { require("telescope.builtin").lsp_definitions, { buffer = event.buf, desc = "[G]o to [d]efinition" } ) - vim.keymap.set( - "n", - "gD", - vim.lsp.buf.declaration, - { buffer = event.buf, desc = "[G]o to [d]eclatation" } - ) vim.keymap.set( "n", "gt", @@ -43,24 +37,28 @@ return { vim.keymap.set( "n", - "fs", + "gs", require("telescope.builtin").lsp_document_symbols, - { buffer = event.buf, desc = "[F]ind symbols" } + { buffer = event.buf, desc = "[F]ind symbols (local)" } ) vim.keymap.set( "n", - "fS", + "gS", require("telescope.builtin").lsp_dynamic_workspace_symbols, { buffer = event.buf, desc = "[F]ind [s]ymbols (global)" } ) - - vim.keymap.set("n", "r", vim.lsp.buf.rename, { buffer = event.buf, desc = "[R]ename" }) - vim.keymap.set( { "n", "x" }, - "ca", + "ga", vim.lsp.buf.code_action, - { buffer = event.buf, desc = "[C]ode [A]ction" } + { buffer = event.buf, desc = "[G]o to [A]ctions" } + ) + vim.keymap.set("n", "r", vim.lsp.buf.rename, { buffer = event.buf, desc = "[R]ename member" }) + vim.keymap.set( + "n", + "ss", + vim.lsp.buf.signature_help, + { buffer = event.buf, desc = "[S]how [s]ignature" } ) -- The following two autocommands are used to highlight references of the @@ -95,10 +93,12 @@ return { -- The following code creates a keymap to toggle inlay hints in your -- code, if the language server you are using supports them -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - vim.keymap.set("n", "ah", function() + if client and (client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint)) then + vim.lsp.inlay_hint.enable(true) + + vim.keymap.set("n", "sh", function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })) - end, { buffer = event.buf, desc = "Inlay [h]ints" }) + end, { buffer = event.buf, desc = "[S]how inlay [h]ints" }) end end, }) @@ -109,6 +109,7 @@ return { require("mason").setup() require("mason-lspconfig").setup({ + automatic_installation = false, ensure_installed = { "lua_ls", "rust_analyzer", "ts_ls", "denols" }, }) @@ -133,6 +134,18 @@ return { require("lspconfig").ts_ls.setup({ root_dir = require("lspconfig").util.root_pattern("package.json"), single_file_support = false, + init_options = { + preferences = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = true, + includeInlayVariableTypeHints = true, + includeInlayFunctionParameterTypeHints = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + importModuleSpecifierPreference = "non-relative", + }, + }, capabilities = vim.tbl_deep_extend( "force", {}, @@ -172,5 +185,15 @@ return { }, }, }) + + -- rust + require("lspconfig").rust_analyzer.setup({ + capabilities = vim.tbl_deep_extend( + "force", + {}, + capabilities_extended, + require("lspconfig").rust_analyzer.capabilities or {} + ), + }) end, } diff --git a/nvim/lua/pawelgrzybek/plugins/nvim-cmp.lua b/nvim/lua/pawelgrzybek/plugins/nvim-cmp.lua index 3d9fa39..ed70024 100644 --- a/nvim/lua/pawelgrzybek/plugins/nvim-cmp.lua +++ b/nvim/lua/pawelgrzybek/plugins/nvim-cmp.lua @@ -84,18 +84,6 @@ return { -- $body -- end -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [""] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { "i", "s" }), -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps