feat: add neovim rest client
This commit is contained in:
parent
86614ce715
commit
92ef625f62
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.NERDTreeCustomOpenArgs = {file = {where = "t"}}
|
||||
g.hidden = true
|
||||
g.material_style = "deep ocean"
|
||||
require("transparent").setup({enable = 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
|
||||
|
@ -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 = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
['<S-Tab>'] = function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
|
||||
elseif luasnip.jumpable(-1) then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>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)
|
||||
|
@ -9,7 +9,8 @@ map("n", " ", "<Nop>", remap)
|
||||
g.mapleader = " "
|
||||
|
||||
map("n", "<C-p>", ":Telescope find_files<CR>", options)
|
||||
|
||||
map("n", "<C-f>", ":Telescope grep_string<CR>", options);
|
||||
map("n", "<Leader><C-f>", ":Telescope live_grep<CR>", options);
|
||||
-- Navigate Buffers
|
||||
map("n", "<C-h>", "<C-w>h", options)
|
||||
map("n", "<C-j>", "<C-w>j", options)
|
||||
@ -22,6 +23,9 @@ map("n", "<Right>", ":echo 'No Right for you'<CR><dw>", options)
|
||||
map("n", "<Up>", ":echo 'No Up for you'<CR><dw>", options)
|
||||
map("n", "<Down>", ":echo 'No Down for you'<CR><dw>", options)
|
||||
|
||||
-- Run Requests
|
||||
map("n", "<Leader>r", "<cmd>lua require('rest-nvim').run()<CR>", options)
|
||||
|
||||
-- Close on q
|
||||
map("n", "<Leader>q", "<Esc>:q<CR>", options)
|
||||
|
||||
|
@ -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"
|
||||
|
||||
-- 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
|
||||
-- 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,
|
||||
|
Loading…
Reference in New Issue
Block a user