From bb092ad64977f8c0abfefb364be2c59e43082543 Mon Sep 17 00:00:00 2001 From: jaydamani Date: Wed, 31 Mar 2021 15:08:29 +0530 Subject: [PATCH 1/6] fixed mappings for lspconfigs --- lua/nvim-lspconfig/lua.lua | 66 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/lua/nvim-lspconfig/lua.lua b/lua/nvim-lspconfig/lua.lua index 6042601..98ba1ae 100644 --- a/lua/nvim-lspconfig/lua.lua +++ b/lua/nvim-lspconfig/lua.lua @@ -1,34 +1,44 @@ vim.cmd [[packadd nvim-lspconfig]] 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, ...) + + 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') + + -- Mappings. + local opts = { noremap=true, silent=true } + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) + elseif client.resolved_capabilities.document_range_formatting then + buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) + end + +end + +local servers = { "tsserver" } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { on_attach = on_attach } end -buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") --- Mappings. -local opts = {noremap = true, silent = true} -buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) -buf_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", opts) -buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) -buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", opts) -buf_set_keymap("n", "", "lua vim.lsp.buf.signature_help()", opts) -buf_set_keymap("n", "wa", "lua vim.lsp.buf.add_workspace_folder()", opts) -buf_set_keymap("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()", opts) -buf_set_keymap("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", opts) -buf_set_keymap("n", "D", "lua vim.lsp.buf.type_definition()", opts) -buf_set_keymap("n", "rn", "lua vim.lsp.buf.rename()", opts) -buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", opts) -buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) -buf_set_keymap("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", opts) -buf_set_keymap("n", "]d", "lua vim.lsp.diagnostic.goto_next()", opts) -buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) - --- lsp for html , css and js/ts -require "lspconfig".tsserver.setup {} -require "lspconfig".cssls.setup {} -require "lspconfig".html.setup {} From 02ac9387190de8c1470229d3a18d71b9bc688fab Mon Sep 17 00:00:00 2001 From: jaydamani Date: Wed, 31 Mar 2021 15:17:11 +0530 Subject: [PATCH 2/6] added new keybinds for bufferline --- lua/bufferline/lua.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/bufferline/lua.lua b/lua/bufferline/lua.lua index d3a8cf9..2f6d37d 100644 --- a/lua/bufferline/lua.lua +++ b/lua/bufferline/lua.lua @@ -57,6 +57,11 @@ local opt = {silent = true} vim.g.mapleader = " " +--command that adds new buffer and moves to it +vim.api.nvim_command "com -nargs=? -complete=file_in_path New badd | blast" +vim.api.nvim_set_keymap("n","",":New ", opt) +--removing a buffer +vim.api.nvim_set_keymap("n","",[[bdelete]], opt) -- tabnew and tabprev -vim.api.nvim_set_keymap("n", "tn", [[BufferLineCycleNext]], opt) -vim.api.nvim_set_keymap("n", "tp", [[BufferLineCyclePrev]], opt) +vim.api.nvim_set_keymap("n", "", [[BufferLineCycleNext]], opt) +vim.api.nvim_set_keymap("n", "", [[BufferLineCyclePrev]], opt) From 40cc37d23fd8a065d856b42016ebdb68082fa7cc Mon Sep 17 00:00:00 2001 From: jaydamani Date: Wed, 31 Mar 2021 15:31:05 +0530 Subject: [PATCH 3/6] added tab completion --- lua/nvim-compe/lua.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/nvim-compe/lua.lua b/lua/nvim-compe/lua.lua index ef2a6e5..84b40d5 100644 --- a/lua/nvim-compe/lua.lua +++ b/lua/nvim-compe/lua.lua @@ -33,6 +33,16 @@ require "compe".setup { local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end + +_G.tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "" + elseif check_back_space() then + return t "" + else + return vim.fn['compe#complete']() + end +end _G.s_tab_complete = function() if vim.fn.pumvisible() == 1 then return t "" @@ -45,6 +55,7 @@ end -- mappings +vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) From f791ac2e25b7cc6bfe896532aff0c7ce4128695c Mon Sep 17 00:00:00 2001 From: jaydamani Date: Wed, 31 Mar 2021 16:58:50 +0530 Subject: [PATCH 4/6] fixed an oopsie --- install.sh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index 9307287..c042a3c 100755 --- a/install.sh +++ b/install.sh @@ -2,8 +2,8 @@ BASE=$(git rev-parse --show-toplevel) LSP_BIN_PATH=$HOME/.local/bin -default_lsp_langs="css html ts rust" -lsp_langs=${@:-"$default_lsp_langs"} +supported_lsp_langs="css html ts rust" +lsp_langs=${@:-"$supported_lsp_langs"} pfx="~~~~~ " heading() { @@ -35,8 +35,8 @@ heading "old nvim config will be deleted so watchout :0" # copying config -rm -rf ~/.config/nvim/ && mkdir ~/.config/nvim -cp -r init.lua ~/.config/nvim && cp -r lua ~/.config/nvim +#rm -rf ~/.config/nvim/ && mkdir ~/.config/nvim +#cp -r init.lua ~/.config/nvim && cp -r lua ~/.config/nvim #for f in `find -E . -regex ".*\.vim$|.*\.lua$"`; do # p=${f#*/} @@ -86,14 +86,11 @@ install_rust() { fi } -for lang in ${lsp_langs}; do - if fn_exists install_$lang ; then - heading "Installing $lang language server" - install_$lang - else - echo $lang setup not implemented - echo - fi +echo 'select languages you would be developing in.' +select lang in ${lsp_langs}; do + heading "Installing $lang language server" + install_$lang + echo done if [[ ${warn_path} = true ]]; then From 7906e1ce0a4c8d1b4cf684e47c8626d92a026637 Mon Sep 17 00:00:00 2001 From: jaydamani Date: Wed, 31 Mar 2021 17:39:19 +0530 Subject: [PATCH 5/6] fixing --- install.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index c042a3c..9307287 100755 --- a/install.sh +++ b/install.sh @@ -2,8 +2,8 @@ BASE=$(git rev-parse --show-toplevel) LSP_BIN_PATH=$HOME/.local/bin -supported_lsp_langs="css html ts rust" -lsp_langs=${@:-"$supported_lsp_langs"} +default_lsp_langs="css html ts rust" +lsp_langs=${@:-"$default_lsp_langs"} pfx="~~~~~ " heading() { @@ -35,8 +35,8 @@ heading "old nvim config will be deleted so watchout :0" # copying config -#rm -rf ~/.config/nvim/ && mkdir ~/.config/nvim -#cp -r init.lua ~/.config/nvim && cp -r lua ~/.config/nvim +rm -rf ~/.config/nvim/ && mkdir ~/.config/nvim +cp -r init.lua ~/.config/nvim && cp -r lua ~/.config/nvim #for f in `find -E . -regex ".*\.vim$|.*\.lua$"`; do # p=${f#*/} @@ -86,11 +86,14 @@ install_rust() { fi } -echo 'select languages you would be developing in.' -select lang in ${lsp_langs}; do - heading "Installing $lang language server" - install_$lang - echo +for lang in ${lsp_langs}; do + if fn_exists install_$lang ; then + heading "Installing $lang language server" + install_$lang + else + echo $lang setup not implemented + echo + fi done if [[ ${warn_path} = true ]]; then From 32404821917d74f74b962a9d2e4f13c67e369ada Mon Sep 17 00:00:00 2001 From: jaydamani Date: Wed, 31 Mar 2021 17:43:17 +0530 Subject: [PATCH 6/6] forgot a fuction --- lua/nvim-compe/lua.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/nvim-compe/lua.lua b/lua/nvim-compe/lua.lua index 84b40d5..df6b263 100644 --- a/lua/nvim-compe/lua.lua +++ b/lua/nvim-compe/lua.lua @@ -34,6 +34,16 @@ local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) 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 ""