diff --git a/init.lua b/init.lua index 5cb851c..ded8568 100644 --- a/init.lua +++ b/init.lua @@ -86,7 +86,7 @@ require('lazy').setup({ -- Useful status updates for LSP -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', @@ -110,7 +110,7 @@ require('lazy').setup({ }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, + { 'folke/which-key.nvim', opts = {} }, { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', @@ -124,7 +124,8 @@ require('lazy').setup({ changedelete = { text = '~' }, }, on_attach = function(bufnr) - vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) + vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, + { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) vim.keymap.set('n', 'gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) end, @@ -486,4 +487,11 @@ luasnip.config.setup {} -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et -require 'lua.custom' +require('custom.options') +require('custom.keymaps') +require('custom.catppuccin') +require('custom.startup') +require('custom.lua-line') +require('custom.telescope') +require('custom.lspconfig') +vim.cmd([[source ~/repos/nvim-kickstart/lua/custom/vimrc]]) diff --git a/lua/custom/catppuccin.lua b/lua/custom/catppuccin.lua new file mode 100644 index 0000000..f9d835b --- /dev/null +++ b/lua/custom/catppuccin.lua @@ -0,0 +1,51 @@ +-- vim.cmd([[colorscheme gruvbox]]) +-- local status, _ = pcall(vim.cmd, "colorscheme gruvbox") +-- if not status then +-- print("Colorscheme not found!") -- print error if colorscheme not installed +-- return +-- end + +require("catppuccin").setup({ + flavour = "frappe", -- latte, frappe, macchiato, mocha + background = { -- :h background + light = "latte", + dark = "mocha", + }, + transparent_background = true, + term_colors = false, + dim_inactive = { + enabled = false, + shade = "dark", + percentage = 0.15, + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + styles = { + comments = { "italic" }, + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + custom_highlights = {}, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + telescope = true, + notify = false, + mini = false, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, +}) + +-- setup must be called before loading +vim.cmd.colorscheme "catppuccin" diff --git a/lua/custom/init.lua b/lua/custom/init.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua index 5c37174..8a021cf 100644 --- a/lua/custom/keymaps.lua +++ b/lua/custom/keymaps.lua @@ -5,10 +5,10 @@ local keymap = vim.keymap keymap.set('i', 'jj', '') keymap.set('n', 'nh', ':nohl', { silent = true }) -keymap.set('n', 'to', ':tabnew', { silent = true }) -- open new tab +keymap.set('n', 'to', ':tabnew', { silent = true }) -- open new tab keymap.set('n', 'tx', ':tabclose', { silent = true }) -- close current tab -keymap.set('n', 'tn', ':tabn', { silent = true }) -- go to next tab -keymap.set('n', 'tp', ':tabp', { silent = true }) -- go to previous tab +keymap.set('n', 'tn', ':tabn', { silent = true }) -- go to next tab +keymap.set('n', 'tp', ':tabp', { silent = true }) -- go to previous tab keymap.set('n', 'gn', ':bn', { silent = true }) keymap.set('n', 'gp', ':bp') @@ -30,17 +30,17 @@ keymap.set('n', 'y', '"+yy') -- Plugin Keybinds ---------------------- --- nvim-tree -keymap.set('n', 'e', ':NvimTreeToggle', { silent = true }) -- toggle file explorer -keymap.set('n', 'gt', ':NvimTreeFindFile', { silent = true }) -- toggle file explorer +-- neo-tree +keymap.set('n', 'e', ':Neotree toggle', { noremap = true, silent = true }) -- toggle file explorer +keymap.set('n', 'gt', ':Neotree toggle left reveal_force_cwd', { silent = true }) -- toggle file explorer -- telescope -keymap.set('n', 'sf', 'Telescope find_files', { silent = true }) -- find files within current working directory, respects .gitignore -keymap.set('n', 'sg', 'Telescope live_grep', { silent = true }) -- find string in current working directory as you type +keymap.set('n', 'sf', 'Telescope find_files', { silent = true }) -- find files within current working directory, respects .gitignore +keymap.set('n', 'sg', 'Telescope live_grep', { silent = true }) -- find string in current working directory as you type keymap.set('n', 'sc', 'Telescope grep_string', { silent = true }) -- find string under cursor in current working directory -keymap.set('n', 'sb', 'Telescope buffers', { silent = true }) -- list open buffers in current neovim instance -keymap.set('n', 'sh', 'Telescope help_tags', { silent = true }) -- list available help tags -keymap.set('n', 'sk', 'Telescope keymaps', { silent = true }) -- list available help tags +keymap.set('n', 'sb', 'Telescope buffers', { silent = true }) -- list open buffers in current neovim instance +keymap.set('n', 'sh', 'Telescope help_tags', { silent = true }) -- list available help tags +keymap.set('n', 'sk', 'Telescope keymaps', { silent = true }) -- list available help tags -- git merge keymap.set('n', '1', ':diffget LOCAL') diff --git a/lua/custom/lspconfig.lua b/lua/custom/lspconfig.lua new file mode 100644 index 0000000..5c49d24 --- /dev/null +++ b/lua/custom/lspconfig.lua @@ -0,0 +1,179 @@ +-- import lspconfig plugin safely +local lspconfig_status, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status then + return +end + +-- import cmp-nvim-lsp plugin safely +local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not cmp_nvim_lsp_status then + return +end + +local keymap = vim.keymap -- for conciseness + +-- enable keybinds only for when lsp server available +local on_attach = function(_, bufnr) + -- keybind options + local opts = { noremap = true, silent = true, buffer = bufnr } + + keymap.set("n", "g0", "lua vim.lsp.buf.document_symbol()", opts) + keymap.set("n", "gr", "lua vim.lsp.buf.references()", opts) + keymap.set("n", "gD", "lua vim.lsp.buf.declaration()", opts) -- got to declaration + keymap.set("n", "gd", "lua vim.lsp.buf.definition()", opts) -- see definition and make edits in window + keymap.set("n", "gi", "lua vim.lsp.buf.implementation()", opts) -- go to implementation + keymap.set("n", "l", "lua vim.lsp.buf.format()", opts) -- format code + keymap.set("n", "rn", "lua vim.lsp.buf.rename()", opts) -- format code + keymap.set("n", "ca", "lua vim.lsp.buf.code_action()", opts) -- see available code actions + keymap.set("n", "ed", "Telescope diagnostics", opts) -- jump to previous diagnostic in buffer + keymap.set( + "n", + "cbf", + ":!phpcbf -w --standard=PSR12 %", + { noremap = true, silent = false, buffer = bufnr } + ) + + keymap.set("n", "o", "LSoutlineToggle", opts) -- see outline on right hand side +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 + +local lsp_flags = { + -- This is the default in Nvim 0.7+ + debounce_text_changes = 150, +} + +lspconfig["bashls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "sh", "bin" }, +}) + +-- XML LSP +lspconfig["lemminx"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "xml" }, +}) + +-- yaml LSP +lspconfig["yamlls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "yaml", "yml" }, +}) +-- json LSP +lspconfig["jsonls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "json" }, +}) + +lspconfig["pyright"].setup({ + on_attach = on_attach, + flags = lsp_flags, + filetypes = { "py" }, +}) + +-- configure html server +lspconfig["html"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html" }, +}) + +-- configure css server +lspconfig["cssls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, +}) + +-- configure tailwindcss server +lspconfig["tailwindcss"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, +}) + +-- configure emmet language server +lspconfig["emmet_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, +}) + +lspconfig["eslint"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, +}) + +-- rust +lspconfig["rust_analyzer"].setup({ + on_attach = on_attach, + capabilities = capabilities, + flags = lsp_flags, + -- Server-specific settings... + settings = { + ["rust-analyzer"] = { + -- enable clippy on save + checkOnSave = { + command = "clippy", + }, + }, + }, +}) + +lspconfig["yamlls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "yml", "yaml" }, +}) + +-- -- configure lua server (with special settings) +lspconfig["lua_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { -- custom settings for lua + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, + filetypes = { "lua" }, +}) + +lspconfig["phpactor"].setup({ + on_attach = on_attach, + capabilities = capabilities, + init_options = { + ["language_server_phpstan.enabled"] = true, + ["language_server_psalm.enabled"] = false, + }, + filetypes = { "php" }, +}) + +lspconfig["intelephense"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "php" }, +}) diff --git a/lua/custom/lua-line.lua b/lua/custom/lua-line.lua new file mode 100644 index 0000000..e39c1e3 --- /dev/null +++ b/lua/custom/lua-line.lua @@ -0,0 +1,45 @@ +-- import lualine plugin safely +local status, lualine = pcall(require, "lualine") +if not status then + return +end + +-- get lualine nightfly theme +local lualine_nightfly = require("lualine.themes.nightfly") +local lualine_codedark = require("lualine.themes.codedark") + +-- new colors for theme +local new_colors = { + blue = "#65D1FF", + green = "#3EFFDC", + violet = "#FF61EF", + yellow = "#FFDA7B", + black = "#000000", + red = "#b23232", +} + +-- change nightlfy theme colors +lualine_nightfly.normal.a.bg = new_colors.blue +lualine_nightfly.insert.a.bg = new_colors.red +lualine_nightfly.visual.a.bg = new_colors.violet +lualine_nightfly.command = { + a = { + gui = "bold", + bg = new_colors.yellow, + fg = new_colors.black, -- black + }, +} + +-- configure lualine with modified theme +lualine.setup({ + options = { + theme = lualine_nightfly, + -- theme = lualine_codedark, + }, + sections = { + lualine_c = { + { "filename", path = 1 }, + "lsp_progress", + }, + }, +}) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d..3a1fffa 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,16 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + -- add, delete, change surroundings it's awesome + "tpope/vim-surround", + -- -- commenting with gc + "numToStr/Comment.nvim", + + "arkav/lualine-lsp-progress", + "christoomey/vim-tmux-navigator", -- tmux & split window navigation + "nvim-telescope/telescope-project.nvim", + "catppuccin/nvim", + as = "catppuccin", + { "startup-nvim/startup.nvim", dependencies = "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }, +} diff --git a/lua/custom/startup.lua b/lua/custom/startup.lua new file mode 100644 index 0000000..c5d2f22 --- /dev/null +++ b/lua/custom/startup.lua @@ -0,0 +1,8 @@ +-- import comment plugin safely +local setup, startup = pcall(require, "startup") +if not setup then + return +end + +-- enable startup +startup.setup() diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua new file mode 100644 index 0000000..ef9e67c --- /dev/null +++ b/lua/custom/telescope.lua @@ -0,0 +1,36 @@ +-- import telescope plugin safely +local telescope_setup, telescope = pcall(require, "telescope") +if not telescope_setup then + return +end + +-- import telescope actions safely +local actions_setup, actions = pcall(require, "telescope.actions") +if not actions_setup then + return +end + +-- configure telescope +telescope.setup({ + -- configure custom mappings + defaults = { + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected to quickfixlist + }, + }, + }, +}) + +telescope.load_extension("fzf") +telescope.load_extension("project") +-- telescope.load_extension("dap") + +vim.api.nvim_set_keymap( + "n", + "", + ":lua require'telescope'.extensions.project.project{}", + { noremap = true, silent = true } +)