merge
This commit is contained in:
commit
d5a064740c
14
install.sh
14
install.sh
|
@ -2,7 +2,7 @@
|
||||||
BASE=$(git rev-parse --show-toplevel)
|
BASE=$(git rev-parse --show-toplevel)
|
||||||
LSP_BIN_PATH=$HOME/.local/bin
|
LSP_BIN_PATH=$HOME/.local/bin
|
||||||
|
|
||||||
default_lsp_langs="css html ts rust"
|
default_lsp_langs="css html ts rust python"
|
||||||
lsp_langs=${@:-"$default_lsp_langs"}
|
lsp_langs=${@:-"$default_lsp_langs"}
|
||||||
|
|
||||||
pfx="~~~~~ "
|
pfx="~~~~~ "
|
||||||
|
@ -63,6 +63,14 @@ install_node_deps () {
|
||||||
sudo npm install -g $@
|
sudo npm install -g $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_python_deps () {
|
||||||
|
if [[ -z $(which pip) ]]; then
|
||||||
|
echo "python/pip not installed"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sudo python3 -m pip install $@
|
||||||
|
}
|
||||||
|
|
||||||
install_ts() {
|
install_ts() {
|
||||||
install_node_deps typescript typescript-language-server prettier
|
install_node_deps typescript typescript-language-server prettier
|
||||||
}
|
}
|
||||||
|
@ -86,6 +94,10 @@ install_rust() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_python(){
|
||||||
|
install_python_deps 'python-language-server[all]'
|
||||||
|
}
|
||||||
|
|
||||||
for lang in ${lsp_langs}; do
|
for lang in ${lsp_langs}; do
|
||||||
if fn_exists install_$lang ; then
|
if fn_exists install_$lang ; then
|
||||||
heading "Installing $lang language server"
|
heading "Installing $lang language server"
|
||||||
|
|
|
@ -57,6 +57,11 @@ local opt = {silent = true}
|
||||||
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
--command that adds new buffer and moves to it
|
||||||
|
vim.api.nvim_command "com -nargs=? -complete=file_in_path New badd <args> | blast"
|
||||||
|
vim.api.nvim_set_keymap("n","<S-b>",":New ", opt)
|
||||||
|
--removing a buffer
|
||||||
|
vim.api.nvim_set_keymap("n","<S-f>",[[<Cmd>bdelete<CR>]], opt)
|
||||||
-- tabnew and tabprev
|
-- tabnew and tabprev
|
||||||
vim.api.nvim_set_keymap("n", "<Leader>tn", [[<Cmd>BufferLineCycleNext<CR>]], opt)
|
vim.api.nvim_set_keymap("n", "<S-l>", [[<Cmd>BufferLineCycleNext<CR>]], opt)
|
||||||
vim.api.nvim_set_keymap("n", "<Leader>tp", [[<Cmd>BufferLineCyclePrev<CR>]], opt)
|
vim.api.nvim_set_keymap("n", "<S-s>", [[<Cmd>BufferLineCyclePrev<CR>]], opt)
|
||||||
|
|
|
@ -33,6 +33,26 @@ require "compe".setup {
|
||||||
local t = function(str)
|
local t = function(str)
|
||||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local check_back_space = function()
|
||||||
|
local col = vim.fn.col('.') - 1
|
||||||
|
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
_G.tab_complete = function()
|
||||||
|
if vim.fn.pumvisible() == 1 then
|
||||||
|
return t "<C-n>"
|
||||||
|
elseif check_back_space() then
|
||||||
|
return t "<Tab>"
|
||||||
|
else
|
||||||
|
return vim.fn['compe#complete']()
|
||||||
|
end
|
||||||
|
end
|
||||||
_G.s_tab_complete = function()
|
_G.s_tab_complete = function()
|
||||||
if vim.fn.pumvisible() == 1 then
|
if vim.fn.pumvisible() == 1 then
|
||||||
return t "<C-p>"
|
return t "<C-p>"
|
||||||
|
@ -45,6 +65,7 @@ end
|
||||||
|
|
||||||
-- mappings
|
-- mappings
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||||
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||||
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||||
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||||
|
|
|
@ -1,34 +1,42 @@
|
||||||
vim.cmd [[packadd nvim-lspconfig]]
|
vim.cmd [[packadd nvim-lspconfig]]
|
||||||
vim.cmd [[packadd nvim-compe]]
|
vim.cmd [[packadd nvim-compe]]
|
||||||
|
local nvim_lsp = require('lspconfig')
|
||||||
|
function on_attach(client)
|
||||||
|
|
||||||
local function buf_set_keymap(...)
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
|
||||||
end
|
|
||||||
local function buf_set_option(...)
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
|
||||||
end
|
|
||||||
|
|
||||||
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||||
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||||
|
|
||||||
-- Mappings.
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
local opts = {noremap = true, silent = true}
|
|
||||||
buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
|
|
||||||
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
|
||||||
|
|
||||||
-- lsp for html , css and js/ts
|
-- Mappings.
|
||||||
require "lspconfig".tsserver.setup {}
|
local opts = { noremap=true, silent=true }
|
||||||
require "lspconfig".cssls.setup {}
|
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
require "lspconfig".html.setup {}
|
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||||
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||||
|
|
||||||
|
-- Set some keybinds conditional on server capabilities
|
||||||
|
if client.resolved_capabilities.document_formatting then
|
||||||
|
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||||
|
elseif client.resolved_capabilities.document_range_formatting then
|
||||||
|
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local servers = { "tsserver", "cssls", "pyls", "html" }
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
nvim_lsp[lsp].setup { on_attach = on_attach }
|
||||||
|
end
|
Loading…
Reference in New Issue