diff options
| author | ozpv <39195175+ozpv@users.noreply.github.com> | 2024-06-15 14:24:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-15 14:24:52 +0000 |
| commit | 0449e6bd58281091e3204b220e1a77a9c976254b (patch) | |
| tree | 030777724605bc7231be9f534d592536c29041ff | |
| parent | 90cbd724ce0d2d30c694370e52e43d9994d49459 (diff) | |
update shells
| -rw-r--r-- | configuration.nix | 2 | ||||
| -rw-r--r-- | nvim/init.lua | 4 | ||||
| -rw-r--r-- | nvim/lua/config/keymapping.lua | 16 | ||||
| -rw-r--r-- | nvim/lua/config/options.lua | 19 | ||||
| -rw-r--r-- | nvim/lua/lazy.lua | 495 | ||||
| -rw-r--r-- | nvim/lua/plugins/lsp.lua | 0 | ||||
| -rw-r--r-- | nvim/lua/plugins/telescope.lua | 30 | ||||
| -rw-r--r-- | nvim/lua/plugins/treesitter.lua | 14 | ||||
| -rw-r--r-- | shells/all.nix | 3 | ||||
| -rw-r--r-- | shells/haemolacriaa.nix | 2 |
10 files changed, 580 insertions, 5 deletions
diff --git a/configuration.nix b/configuration.nix index 7c4e2b6..aa0c707 100644 --- a/configuration.nix +++ b/configuration.nix @@ -94,7 +94,7 @@ (st.overrideAttrs { src = fetchGit { url = "https://github.com/ozpv/st.git"; - rev = "b1281f13579b710c443f0127f5ca49da36fe26b2"; + rev = "3a3cb60a329fc9dd139cd7a38e73307be791b480"; }; }) (dmenu.overrideAttrs { diff --git a/nvim/init.lua b/nvim/init.lua index 9d68927..dc268d2 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,3 +1,3 @@ require("plugins.lazy") -require("options") -require("keymapping") +require("config.options") +require("config.keymapping") diff --git a/nvim/lua/config/keymapping.lua b/nvim/lua/config/keymapping.lua new file mode 100644 index 0000000..cebb621 --- /dev/null +++ b/nvim/lua/config/keymapping.lua @@ -0,0 +1,16 @@ +-- clipboard -- +vim.keymap.set({"n", "v"}, "<leader>y", [["+y]], { desc = "Copy to clipboard" }) +vim.keymap.set({"n", "v"}, "<leader>y", [["+p]], { desc = "Paste from clipboard" }) + +-- splits -- +vim.keymap.set("n", "<leader>sv", [[<C-w>v]], { desc = "Split window vertically" }) +vim.keymap.set("n", "<leader>sh", [[<C-w>s]], { desc = "Split window horizontally" }) +vim.keymap.set("n", "<leader>se", [[<C-w>=]], { desc = "Reset split size to default" }) +vim.keymap.set("n", "<leader>sw", [[close]], { desc = "Close current split" }) + +-- tabs -- +vim.keymap.set("n", "<leader>to", [[tabnew]], { desc = "Open new tab" }) +vim.keymap.set("n", "<leader>tw", [[tabclose]], { desc = "Close current tab" }) +vim.keymap.set("n", "<leader>tl", [[tabn]], { desc = "Go to next tab" }) +vim.keymap.set("n", "<leader>th", [[tabp]], { desc = "Go to previous tab" }) +vim.keymap.set("n", "<leader>t%", [[tabnew %]], { desc = "Open current buffer in new tab" }) diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua new file mode 100644 index 0000000..994ed77 --- /dev/null +++ b/nvim/lua/config/options.lua @@ -0,0 +1,19 @@ +vim.g.mapleader = " " + +vim.o.clipboard = "unnamedplus" + +vim.o.number = true + +vim.o.expandtab = true + +vim.o.shiftwidth = 2 + +vim.o.smartindent = true + +vim.o.tabstop = 2 + +vim.o.softtabstop = 2 + +vim.opt.shortmess:append "sI" + +vim.opt.whichwrap:append "<>[]hl" diff --git a/nvim/lua/lazy.lua b/nvim/lua/lazy.lua new file mode 100644 index 0000000..9d5e4aa --- /dev/null +++ b/nvim/lua/lazy.lua @@ -0,0 +1,495 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + -- lazy options + checker = { + enabled = true, + notify = false, + }, + change_detection = { + notify = false, + }, + -- lualine + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + local lualine = require("lualine") + local lazy_status = require("lazy.status") -- to configure lazy pending updates count + + local colors = { + blue = "#65D1FF", + green = "#3EFFDC", + violet = "#FF61EF", + yellow = "#FFDA7B", + red = "#FF4A4A", + fg = "#c3ccdc", + bg = "#112638", + inactive_bg = "#2c3043", + } + + local my_lualine_theme = { + normal = { + a = { bg = colors.blue, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + insert = { + a = { bg = colors.green, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + visual = { + a = { bg = colors.violet, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + command = { + a = { bg = colors.yellow, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + replace = { + a = { bg = colors.red, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + inactive = { + a = { bg = colors.inactive_bg, fg = colors.semilightgray, gui = "bold" }, + b = { bg = colors.inactive_bg, fg = colors.semilightgray }, + c = { bg = colors.inactive_bg, fg = colors.semilightgray }, + }, + } + + -- configure lualine with modified theme + lualine.setup({ + options = { + theme = my_lualine_theme, + }, + sections = { + lualine_x = { + { + lazy_status.updates, + cond = lazy_status.has_updates, + color = { fg = "#ff9e64" }, + }, + { "encoding" }, + { "fileformat" }, + { "filetype" }, + }, + }, + }) + end, + }, + -- bufferline + { + "akinsho/bufferline.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + version = "*", + opts = { + options = { + mode = "tabs", + separator_style = "slant", + }, + }, + }, + -- telescope + { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + + telescope.setup({ + defaults = { + path_display = { "smart" }, + mappings = { + i = { + ["<C-k>"] = actions.move_selection_previous, -- move to prev result + ["<C-j>"] = actions.move_selection_next, -- move to next result + ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, + }, + }, + }, + }) + + telescope.load_extension("fzf") + + vim.keymap.set("n", "<leader>ff", [[Telescope find_files]], { desc = "Fuzzy find files in cwd" }) + vim.keymap.set("n", "<leader>fr", [[Telescope oldfiles]], { desc = "Fuzzy find recent files" }) + vim.keymap.set("n", "<leader>fs", [[Telescope live_grep]], { desc = "Find string in cwd" }) + vim.keymap.set("n", "<leader>fc", [[Telescope grep_string]], { desc = "Find string under cursor in cwd" }) + end, + }, + -- which key + { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 500 + end, + opts = { + }, + }, + -- treesitter + { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", + dependencies = { + "windwp/nvim-ts-autotag", + }, + config = function() + -- import nvim-treesitter plugin + local treesitter = require("nvim-treesitter.configs") + + -- configure treesitter + treesitter.setup({ -- enable syntax highlighting + highlight = { + enable = true, + }, + -- enable indentation + indent = { enable = true }, + -- enable autotagging (w/ nvim-ts-autotag plugin) + autotag = { + enable = true, + }, + -- ensure these language parsers are installed + ensure_installed = { + "json", + "javascript", + "typescript", + "tsx", + "html", + "css", + "prisma", + "markdown", + "markdown_inline", + "svelte", + "graphql", + "bash", + "lua", + "vim", + "dockerfile", + "gitignore", + "query", + "vimdoc", + "c", + "cpp", + "rust", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "<C-space>", + node_incremental = "<C-space>", + scope_incremental = false, + node_decremental = "<bs>", + }, + }, + }) + end, + }, + -- nvim cmp + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + { + "L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release) + -- install jsregexp (optional!). + build = "make install_jsregexp", + }, + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + }, + config = function() + local cmp = require("cmp") + + local luasnip = require("luasnip") + + local lspkind = require("lspkind") + + -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + snippet = { -- configure how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + ["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion + ["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion + ["<C-b>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions + ["<C-e>"] = cmp.mapping.abort(), -- close completion window + ["<CR>"] = cmp.mapping.confirm({ select = false }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + { name = "nvim_lsp" }, -- lsp + }), + + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + end, + }, + -- nvim-autopairs + { + "windwp/nvim-autopairs", + event = { "InsertEnter" }, + dependencies = { + "hrsh7th/nvim-cmp", + }, + config = function() + -- import nvim-autopairs + local autopairs = require("nvim-autopairs") + + -- configure autopairs + autopairs.setup({ + check_ts = true, -- enable treesitter + ts_config = { + lua = { "string" }, -- don't add pairs in lua string treesitter nodes + javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes + java = false, -- don't check treesitter on java + }, + }) + + -- import nvim-autopairs completion functionality + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + + -- import nvim-cmp plugin (completions plugin) + local cmp = require("cmp") + + -- make autopairs and completion work together + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, + }, + -- gruvbox colorscheme + { + "ellisonleao/gruvbox.nvim", + name = "gruvbox", + priority = 1000, + lazy = false, + config = function() + vim.cmd([[colorscheme gruvbox]]) + end, + }, + -- mason.nvim + { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + }, + config = function() + -- import mason + local mason = require("mason") + + -- import mason-lspconfig + local mason_lspconfig = require("mason-lspconfig") + + -- enable mason and configure icons + mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) + + mason_lspconfig.setup({ + -- list of servers for mason to install + ensure_installed = { + "tsserver", + "html", + "cssls", + "tailwindcss", + "svelte", + "lua_ls", + "graphql", + "emmet_ls", + "prismals", + "pyright", + }, + }) + end, + }, + -- nvim-lspconfig + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + { "folke/neodev.nvim", opts = {} }, + }, + config = function() + -- import lspconfig plugin + local lspconfig = require("lspconfig") + + -- import mason_lspconfig plugin + local mason_lspconfig = require("mason-lspconfig") + + -- import cmp-nvim-lsp plugin + local cmp_nvim_lsp = require("cmp_nvim_lsp") + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf, silent = true } + + -- set keybinds + opts.desc = "Show LSP references" + vim.keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references + + opts.desc = "Go to declaration" + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desc = "Show LSP definitions" + vim.keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + vim.keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + vim.keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = "Smart rename" + vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + vim.keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = "Go to previous diagnostic" + vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + + opts.desc = "Go to next diagnostic" + vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer + + opts.desc = "Show documentation for what is under cursor" + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + + opts.desc = "Restart LSP" + vim.keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary + end, + }) + + -- used to enable autocompletion (assign to every lsp server config) + local capabilities = cmp_nvim_lsp.default_capabilities() + + -- Change the Diagnostic symbols in the sign column (gutter) + -- (not in youtube nvim video) + local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + mason_lspconfig.setup_handlers({ + -- default handler for installed servers + function(server_name) + lspconfig[server_name].setup({ + capabilities = capabilities, + }) + end, + ["svelte"] = function() + -- configure svelte server + lspconfig["svelte"].setup({ + capabilities = capabilities, + on_attach = function(client, bufnr) + vim.api.nvim_create_autocmd("BufWritePost", { + pattern = { "*.js", "*.ts" }, + callback = function(ctx) + -- Here use ctx.match instead of ctx.file + client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match }) + end, + }) + end, + }) + end, + ["graphql"] = function() + -- configure graphql language server + lspconfig["graphql"].setup({ + capabilities = capabilities, + filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" }, + }) + end, + ["emmet_ls"] = function() + -- configure emmet language server + lspconfig["emmet_ls"].setup({ + capabilities = capabilities, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, + }) + end, + ["lua_ls"] = function() + -- configure lua server (with special settings) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + settings = { + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + completion = { + callSnippet = "Replace", + }, + }, + }, + }) + end, + }) + end, + }, + { + + }, +}) diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nvim/lua/plugins/lsp.lua diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..0cadb4e --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,30 @@ +return { + defaults = { + -- Default configuration for telescope goes here: + -- config_key = value, + mappings = { + i = { + -- map actions.which_key to <C-h> (default: <C-/>) + -- actions.which_key shows the mappings for your picker, + -- e.g. git_{create, delete, ...}_branch for the git_branches picker + ["<C-h>"] = "which_key" + } + } + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + }, + extensions = { + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + } +} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..4b0360f --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + ensure_installed = { + "lua", + "vim", + "vimdoc", + }, + + highlight = { + enable = true, + use_languagetree = true, + }, + + indent.enable = true, +} diff --git a/shells/all.nix b/shells/all.nix index de1cf4b..fb68f81 100644 --- a/shells/all.nix +++ b/shells/all.nix @@ -8,6 +8,7 @@ pkgs.mkShell { xorg.libXft.dev xorg.libXinerama.dev rustc + rustup rust-analyzer rustfmt trunk @@ -19,7 +20,7 @@ pkgs.mkShell { cargo-generate tailwindcss binaryen - sqlite + postgresql sqlx-cli ]; } diff --git a/shells/haemolacriaa.nix b/shells/haemolacriaa.nix index 3dd78b5..da9e7dc 100644 --- a/shells/haemolacriaa.nix +++ b/shells/haemolacriaa.nix @@ -15,7 +15,7 @@ pkgs.mkShell { cargo-generate tailwindcss binaryen - sqlite + postgresql sqlx-cli ]; } |
