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) diff --git a/lua/nvim-compe/lua.lua b/lua/nvim-compe/lua.lua index ef2a6e5..df6b263 100644 --- a/lua/nvim-compe/lua.lua +++ b/lua/nvim-compe/lua.lua @@ -33,6 +33,26 @@ require "compe".setup { 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 "" + 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 +65,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}) diff --git a/lua/nvim-lspconfig/lua.lua b/lua/nvim-lspconfig/lua.lua index 7a447f2..b77f9e8 100644 --- a/lua/nvim-lspconfig/lua.lua +++ b/lua/nvim-lspconfig/lua.lua @@ -1,35 +1,42 @@ 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, ...) -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. -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) + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') --- lsp for html , css and js/ts -require "lspconfig".tsserver.setup {} -require "lspconfig".cssls.setup {} -require "lspconfig".html.setup {} -require "lspconfig".pyls.setup {} + -- 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", "cssls", "pyls", "html" } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { on_attach = on_attach } +end \ No newline at end of file