diff --git a/configs/.tmux.conf b/configs/.tmux.conf index dc91e91..28eab2d 100644 --- a/configs/.tmux.conf +++ b/configs/.tmux.conf @@ -9,20 +9,19 @@ bind - split-window -v unbind '"' unbind % -# switch panes using Alt-arrow without prefix -bind -n M-Left select-pane -L -bind -n M-Right select-pane -R -bind -n M-Up select-pane -U -bind -n M-Down select-pane -D - # Enable mouse mode (tmux 2.1 and above) set -g mouse on -# Add some plugins - +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) set -g @plugin 'tmux-plugins/tpm' + +# Add some plugins set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-yank' +set -g @yank_action 'copy-pipe-no-clear' +bind -T copy-mode C-c send -X copy-pipe-no-clear "xsel -i --clipboard" +bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard" set -g @plugin 'dracula/tmux' set -g @dracula-show-powerline true diff --git a/configs/.zshrc b/configs/.zshrc index 3caaab4..3bd36ef 100644 --- a/configs/.zshrc +++ b/configs/.zshrc @@ -72,18 +72,17 @@ if [ -d "$HOME/.local/bin" ] ; then fi #If fdfind is installed force fzf to use it -if type fdfind > /dev/null ; then - - # Feed the output of fd into fzf - # fdfind --type f | fzf - - # Setting fd as the default source for fzf +if type fdfind &> /dev/null ; then export FZF_DEFAULT_COMMAND='fdfind --type f' - - # To apply the command to CTRL-T as well export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" fi +#If ripgrep is installed prefer it over fdfind +if type rg &> /dev/null; then + export FZF_DEFAULT_COMMAND='rg --files' + export FZF_DEFAULT_OPTS='-m --height 50% --border' +fi + # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh @@ -93,3 +92,5 @@ fi export PNPM_HOME="$HOME/.local/share/pnpm" export PATH="$PNPM_HOME:$PATH" + +alias luamake=/home/jim/.local/share/lua-language-server/3rd/luamake/luamake diff --git a/configs/init.lua b/configs/init.lua index 3d75f1b..9d9b83b 100644 --- a/configs/init.lua +++ b/configs/init.lua @@ -1,43 +1,47 @@ local u = require("utils") local o = vim.o -local opt = vim.opt local g = vim.g -local cmd = vim.cmd; +local cmd = vim.cmd require("install-paq") -local paq = require("paq"); -paq:setup({verbose=true}) { +local paq = require("paq") +paq:setup({verbose = true}) { "savq/paq-nvim", -- Let Paq manage itself + -- General Helper Function + "nvim-lua/plenary.nvim", -- Theming Plugins "kaicataldo/material.vim", "ryanoasis/vim-devicons", - "junegunn/fzf", "xiyaowong/nvim-transparent", -- Layout Plugins "preservim/nerdtree", - "preservim/nerdtree", "jistr/vim-nerdtree-tabs", -- Code Navigation + "junegunn/fzf", "nvim-lua/popup.nvim", - "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim", + -- Postman like featuresi + "NTBBloodbath/rest.nvim", -- Syntax / Autocomplete "neovim/nvim-lspconfig", "nvim-lua/lsp-status.nvim", - "hrsh7th/nvim-compe", + "hrsh7th/nvim-cmp", -- Autocompletion plugin + "hrsh7th/cmp-nvim-lsp", -- LSP source for nvim-cmp + "saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp + "L3MON4D3/LuaSnip", -- Snippets plugin {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}, -- Formatting "mhartington/formatter.nvim", -- Git Interface - "akinsho/nvim-toggleterm.lua" + "akinsho/nvim-toggleterm.lua", + -- Database Interface + "tpope/vim-dadbod", + "kristijanhusak/vim-dadbod-ui" } -if u.has_plugin("material") then - - print("Load config") - +if u.has_plugin("cmp") then -- Global options o.number = true o.tabstop = 2 @@ -54,11 +58,15 @@ if u.has_plugin("material") then g.NERDTreeAutoDeleteBuffer = true g.NERDTreeMinimalUI = true g.NERDTreeDirArrows = true - g.NERDTreeCustomOpenArgs={file = {where = 't'}} - g.hidden = true - g.material_style = "deep ocean" - require("transparent").setup({enable = true}) + -- g.NERDTreeCustomOpenArgs = {file = {where = "t"}} + g.hidden = true + g.material_terminal_italics = 1 + g.material_theme_style = "darker" + + cmd("colorscheme material") + -- Remove background color + require("transparent").setup({enable = true}) cmd("highlight Normal guibg=none") cmd("highlight NonText guibg=none") @@ -67,32 +75,58 @@ if u.has_plugin("material") then require "keymappings" -- Treesitter config - require "nvim-treesitter.configs".setup {ensure_installed = {"bash", "svelte", "css", "svelte", "typescript", "javascript", "go", "lua", "yaml"}, highlight = {enable = true}} + local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() + parser_configs.http = { + install_info = { + url = "https://github.com/NTBBloodbath/tree-sitter-http", + files = {"src/parser.c"}, + branch = "main" + } + } + require "nvim-treesitter.configs".setup { + ensure_installed = {"bash", "http", "svelte", "css", "svelte", "typescript", "javascript", "go", "lua", "yaml"}, + highlight = {enable = true} + } -- Toggleterm / Lazygit setup require "lazy-git" + -- Autocommands u.create_augroup( { {"VimEnter", "*", "if (@% == '') | NERDTree | endif"}, - {"BufEnter", "*", 'if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif'} + {"BufEnter", "*", 'if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif'}, + {"BufWinEnter", "*", "NERDTreeMirrorOpen"} + --{"BufEnter", "*", "if &modifiable | NERDTreeFind | wincmd p | endif"} }, "Nerdtree" ) + -- Setup rest.vim + require("rest-nvim").setup( + { + -- Open request results in a horizontal split + result_split_horizontal = false, + -- Skip SSL verification, useful for unknown certificates + skip_ssl_verification = false, + -- Highlight request on run + highlight = { + enabled = true, + timeout = 150 + }, + -- Jump to request line on run + jump_to_request = false + } + ) + -- Autocompletion Setup + o.completeopt = "menuone,noselect" require "autocomplete" -- LSP Config - require "lsp-utils" - opt.completeopt = {"menuone", "noinsert", "noselect"} - opt.shortmess:append({c = true}) - -- Autoformat require "autoformatter" - - else - paq.install(); + paq.install() end diff --git a/configs/lua/autocomplete.lua b/configs/lua/autocomplete.lua index 9178459..ed40b57 100644 --- a/configs/lua/autocomplete.lua +++ b/configs/lua/autocomplete.lua @@ -1,31 +1,51 @@ -require "compe".setup { - enabled = true, - autocomplete = true, - debug = false, - min_length = 1, - preselect = "enable", - throttle_time = 80, - source_timeout = 200, - resolve_timeout = 800, - incomplete_delay = 400, - max_abbr_width = 100, - max_kind_width = 100, - max_menu_width = 100, - documentation = { - border = "none", - winhighlight = "NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder", - max_width = 120, - min_width = 60, - max_height = math.floor(vim.o.lines * 0.3), - min_height = 1 + +-- luasnip setup +local luasnip = require 'luasnip' + +local cmp = require 'cmp' + +cmp.setup { + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') + elseif luasnip.expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-expand-or-jump', true, true, true), '') + else + fallback() + end + end, + [''] = function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') + elseif luasnip.jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-jump-prev', true, true, true), '') + else + fallback() + end + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, }, - source = { - path = true, - buffer = true, - calc = true, - nvim_lsp = true, - nvim_lua = true, - spell = true, - treesitter = true - } } + +-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) diff --git a/configs/lua/keymappings.lua b/configs/lua/keymappings.lua index 50fce50..fce4e57 100644 --- a/configs/lua/keymappings.lua +++ b/configs/lua/keymappings.lua @@ -9,7 +9,8 @@ map("n", " ", "", remap) g.mapleader = " " map("n", "", ":Telescope find_files", options) - +map("n", "", ":Telescope grep_string", options); +map("n", "", ":Telescope live_grep", options); -- Navigate Buffers map("n", "", "h", options) map("n", "", "j", options) @@ -22,6 +23,9 @@ map("n", "", ":echo 'No Right for you'", options) map("n", "", ":echo 'No Up for you'", options) map("n", "", ":echo 'No Down for you'", options) +-- Run Requests +map("n", "r", "lua require('rest-nvim').run()", options) + -- Close on q map("n", "q", ":q", options) diff --git a/configs/lua/lsp-utils.lua b/configs/lua/lsp-utils.lua index a16686e..4a13c0d 100644 --- a/configs/lua/lsp-utils.lua +++ b/configs/lua/lsp-utils.lua @@ -47,19 +47,89 @@ local function on_attach(client) ) end end --- Use a loop to conveniently both setup defined servers --- and map buffer local keybindings when the language server attaches -local servers = { - "tsserver", - "svelte" -} -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - on_attach = on_attach, - capabilities = lsp_status.capabilities - } + +-- Lua Language Server +if vim.fn.has("mac") == 1 then + system_name = "macOS" +elseif vim.fn.has("unix") == 1 then + system_name = "Linux" +elseif vim.fn.has("win32") == 1 then + system_name = "Windows" +else + print("Unsupported system for sumneko") end +local sumneko_root_path = "/home/jim/.local/share/lua-language-server" +local sumneko_binary = sumneko_root_path .. "/bin/" .. system_name .. "/lua-language-server" + +local runtime_path = vim.split(package.path, ";") +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") + +nvim_lsp.sumneko_lua.setup { + on_attach = on_attach, + capabilities = lsp_status.capabilities, + cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + -- Setup your lua path + path = runtime_path + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {"vim"} + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true) + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false + } + } + } +} + +-- Go Language Server + +nvim_lsp.gopls.setup { + on_attach = on_attach, + capabilities = lsp_status.capabilities +} + +-- Svelte Language Server + +nvim_lsp.svelte.setup { + on_attach = on_attach, + capabilities = lsp_status.capabilities +} + +-- Typescript Language Server + +local function organize_imports() + local params = { + command = "_typescript.organizeImports", + arguments = {vim.api.nvim_buf_get_name(0)}, + title = "" + } + vim.lsp.buf.execute_command(params) +end + +nvim_lsp.tsserver.setup { + on_attach = on_attach, + capabilities = lsp_status.capabilities, + commands = { + OrganizeImports = { + organize_imports, + description = "Organize Imports" + } + } +} + -- Setup diagnostics formaters and linters for non LSP provided files nvim_lsp.diagnosticls.setup { on_attach = on_attach,