Skip to content
Snippets Groups Projects
Commit a920a0b6 authored by Tim van Deurzen's avatar Tim van Deurzen
Browse files

Many local changes after some autocomplete issues.

parent 208c46cb
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ local function basic_configuration()
shiftround = true;
encoding = "utf-8";
magic = true;
completeopt = "menuone,noselect";
completeopt = "menu,menuone,noselect";
shada = "!,'300,<50,@100,s10,h";
inccommand = "nosplit";
grepformat = "%f:%l:%c:%m";
......
local lspkind = require("lspkind")
lspkind.init()
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
cmp.setup({
completion = {
completeopt = "menu,menuone,noinsert",
snippet = {
expand = function(args)
--require("luasnip").lsp_expand(args.body)
require("snippy").expand_snippet(args.body)
end,
},
mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(2),
["<C-e>"] = cmp.mapping.close(),
["<c-y>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
["<c-q>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
},
-- Youtube:
-- the order of your sources matter (by default). That gives them priority
-- you can configure:
-- keyword_length
-- priority
-- max_item_count
-- (more?)
sources = {
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "luasnip" },
{ name = "snippy" },
{ name = "buffer", keyword_length = 5 },
},
sorting = {
-- TODO: Would be cool to add stuff like "See variable names before method names" in rust, or something like that.
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
}),
formatting = {
-- Youtube: How to set up nice formatting for your sources.
format = lspkind.cmp_format({
with_text = true,
menu = {
......@@ -103,16 +38,12 @@ cmp.setup({
nvim_lua = "[api]",
path = "[path]",
luasnip = "[snip]",
gh_issues = "[issues]",
},
}),
},
experimental = {
-- I like the new menu better! Nice work hrsh7th
native_menu = false,
-- Let's play with this for a day or two
ghost_text = true,
},
})
......
require('keybindings.compe')
require('keybindings.which_key')
require('keybindings.compe')
vim.api.nvim_set_keymap("i", "<c-x><c-s>", "<Esc><Cmd>w<CR>a", {silent = true, nowait = true})
vim.api.nvim_set_keymap("n", "<c-x><c-s>", "<Cmd>w<CR>", {silent = true})
local wk = require('whichkey_setup')
local wk = require("whichkey_setup")
local keymap = {
f = {
name = '+file',
f = {'<Cmd>Telescope file_browser<CR>', 'browser'},
t = {'<Cmd>NvimTreeToggle<CR>', 'tree'},
},
b = {
name = '+buffer',
b = {'<Cmd>Telescope buffers<CR>', 'buffers'},
},
p = {
name = '+package',
u = {'<Cmd>PackerUpdate<CR>', 'update'},
s = {'<Cmd>PackerSync<CR>', 'sync'},
},
l = {
name = '+lsp',
-- a = {'<Cmd>Lspsaga code_action<CR>', 'code action'},
a = {'<Cmd>lua vim.lsp.buf.code_action()<CR>', 'code action'},
--r = {'<Cmd>Lspsaga rename<CR>', 'rename'},
r = {'<Cmd>lua vim.lsp.buf.rename()<CR>', 'rename'},
s = {'<Cmd>Lspsaga lsp_finder<CR>', 'find'},
p = {'<Cmd>Lspsaga preview_definition<CR>', 'preview definition'},
f = {'<Cmd>lua vim.lsp.buf.formatting()<CR>', 'format'},
d = {'<Cmd>lua vim.lsp.buf.definition()<CR>', 'go to definition'},
i = {'<Cmd>lua vim.lsp.buf.implementation()<CR>', 'go to definition'},
t = {'<Cmd>LspTroubleToggle lsp_workspace_diagnostics<CR>', 'open LspTrouble'},
},
t = {
name = '+telescope',
p = {'<Cmd>Telescope project<CR>', 'projects'},
d = {'<Cmd>Telescope lsp_workspace_diagnostics<CR>', 'diagnostics'},
}
f = {
name = "+file",
f = { "<Cmd>Telescope file_browser<CR>", "browser" },
t = { "<Cmd>NvimTreeToggle<CR>", "tree" },
},
b = {
name = "+buffer",
b = { "<Cmd>Telescope buffers<CR>", "buffers" },
},
q = {
name = "+quickfix",
o = { "<Cmd>copen<CR>", "open quickfix" },
c = { "<Cmd>cclose<CR>", "close quickfix" },
},
p = {
name = "+package",
u = { "<Cmd>PackerUpdate<CR>", "update" },
s = { "<Cmd>PackerSync<CR>", "sync" },
},
l = {
name = "+lsp",
a = { "<Cmd>lua vim.lsp.buf.code_action()<CR>", "code action" },
r = { "<Cmd>lua vim.lsp.buf.rename()<CR>", "rename" },
s = { "<Cmd>lua vim.lsp.buf.references()<CR>", "find" },
p = { "<cmd>lua vim.lsp.buf.hover()<CR>", "preview definition" },
f = { "<Cmd>lua vim.lsp.buf.formatting()<CR>", "format" },
d = { "<Cmd>lua vim.lsp.buf.definition()<CR>", "go to definition" },
i = { "<Cmd>lua vim.lsp.buf.implementation()<CR>", "go to definition" },
t = { "<Cmd>LspTroubleToggle lsp_workspace_diagnostics<CR>", "open LspTrouble" },
},
t = {
name = "+telescope",
p = { "<Cmd>Telescope project<CR>", "projects" },
d = { "<Cmd>Telescope lsp_workspace_diagnostics<CR>", "diagnostics" },
},
}
wk.register_keymap('leader', keymap)
-- b = {'<Cmd>Telescope buffers<CR>', 'buffers'},
-- h = {'<Cmd>Telescope help_tags<CR>', 'help tags'},
-- c = {
-- name = '+commands',
-- c = {'<Cmd>Telescope commands<CR>', 'commands'},
-- h = {'<Cmd>Telescope command_history<CR>', 'history'},
-- },
-- q = {'<Cmd>Telescope quickfix<CR>', 'quickfix'},
-- g = {
-- name = '+git',
-- g = {'<Cmd>Telescope git_commits<CR>', 'commits'},
-- c = {'<Cmd>Telescope git_bcommits<CR>', 'bcommits'},
-- b = {'<Cmd>Telescope git_branches<CR>', 'branches'},
-- s = {'<Cmd>Telescope git_status<CR>', 'status'},
-- },
wk.register_keymap("leader", keymap)
-- b = {'<Cmd>Telescope buffers<CR>', 'buffers'},
-- h = {'<Cmd>Telescope help_tags<CR>', 'help tags'},
-- c = {
-- name = '+commands',
-- c = {'<Cmd>Telescope commands<CR>', 'commands'},
-- h = {'<Cmd>Telescope command_history<CR>', 'history'},
-- },
-- q = {'<Cmd>Telescope quickfix<CR>', 'quickfix'},
-- g = {
-- name = '+git',
-- g = {'<Cmd>Telescope git_commits<CR>', 'commits'},
-- c = {'<Cmd>Telescope git_bcommits<CR>', 'bcommits'},
-- b = {'<Cmd>Telescope git_branches<CR>', 'branches'},
-- s = {'<Cmd>Telescope git_status<CR>', 'status'},
-- },
......@@ -141,6 +141,17 @@ lsp_config.yamlls.setup({
capabilities = capabilities,
})
lsp_config.metals.setup({
capabilities = capabilities,
settings = {
metals = {
superMethodLensesEnabled = true,
showInferredType = true,
showImplicitArguments = true,
},
},
})
lsp_config.dartls.setup({})
lsp_config.ccls.setup({
......@@ -449,3 +460,14 @@ snippets.go = make {
-- TODO: Fix this up so that it actually uses the tree sitter thing
ie = { "if err != nil {", "\treturn err", i(0), "}" },
}
vim.cmd [[augroup lsp]]
vim.cmd [[au!]]
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach({})]]
vim.cmd [[augroup end]]
local metals_config = require("metals").bare_config()
metals_config.settings = {
showImplicitArguments = true,
}
return require("packer").startup(function()
return require("packer").startup(function(use)
use("wbthomason/packer.nvim")
-- Color schemes
......@@ -122,6 +122,7 @@ return require("packer").startup(function()
use({
"folke/lsp-trouble.nvim",
disable = true,
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("trouble").setup({
......@@ -140,15 +141,20 @@ return require("packer").startup(function()
use("hrsh7th/cmp-nvim-lsp")
use("hrsh7th/nvim-cmp")
use({
"saadparwaiz1/cmp_luasnip",
"dcampos/cmp-snippy",
requires = {
"L3MON4D3/LuaSnip",
"dcampos/nvim-snippy",
"honza/vim-snippets",
},
})
-- use({
-- "saadparwaiz1/cmp_luasnip",
-- use "hrsh7th/cmp-vsnip"
-- use "hrsh7th/vim-vsnip"
-- disable = true,
-- requires = {
-- "L3MON4D3/LuaSnip",
-- },
-- })
use("windwp/nvim-autopairs")
......@@ -160,6 +166,13 @@ return require("packer").startup(function()
},
})
use({
"scalameta/nvim-metals",
requires = {
"nvim-lua/plenary.nvim",
},
})
use({
"lewis6991/gitsigns.nvim",
requires = {
......
......@@ -4,7 +4,7 @@ local condition = require('galaxyline.condition')
local vcs = require('galaxyline.provider_vcs')
local buffer = require('galaxyline.provider_buffer')
local fileinfo = require('galaxyline.provider_fileinfo')
local diagnostic = require('galaxyline.provider_diagnostic')
--local diagnostic = require('galaxyline.provider_diagnostic')
local lspclient = require('galaxyline.provider_lsp')
local icons = require('galaxyline.provider_fileinfo').define_file_icon()
......@@ -117,38 +117,38 @@ gls.left = {
}
gls.right = {
{
DiagnosticError = {
provider = diagnostic.get_diagnostic_error,
icon = '  ',
condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
highlight = {colors.red, colors.black}
},
},
{
DiagnosticWarn = {
provider = diagnostic.get_diagnostic_warn,
icon = '  ',
condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
highlight = {colors.yellow, colors.black}
},
},
{
DiagnosticHint = {
provider = diagnostic.get_diagnostic_hint,
icon = '  ',
condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
highlight = {colors.cyan, colors.black}
}
},
{
DiagnosticInfo = {
provider = diagnostic.get_diagnostic_info,
icon = '  ',
condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
highlight = {colors.cyan, colors.black}
}
},
-- {
-- DiagnosticError = {
-- provider = diagnostic.get_diagnostic_error,
-- icon = '  ',
-- condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
-- highlight = {colors.red, colors.black}
-- },
-- },
-- {
-- DiagnosticWarn = {
-- provider = diagnostic.get_diagnostic_warn,
-- icon = '  ',
-- condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
-- highlight = {colors.yellow, colors.black}
-- },
-- },
-- {
-- DiagnosticHint = {
-- provider = diagnostic.get_diagnostic_hint,
-- icon = '  ',
-- condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
-- highlight = {colors.cyan, colors.black}
-- }
-- },
-- {
-- DiagnosticInfo = {
-- provider = diagnostic.get_diagnostic_info,
-- icon = '  ',
-- condition = function() return condition.check_active_lsp() and condition.hide_in_width() end,
-- highlight = {colors.cyan, colors.black}
-- }
-- },
{
LspStatus = {
provider = function() return string.format(' %s ', lspclient.get_lsp_client()) end,
......
......@@ -20,36 +20,36 @@ ts_configs.setup {
smart_rename = {enable = true, keymaps = {smart_rename = "grr"}},
highlight_definitions = {enable = true},
highlight_current_scope = { enable = false }
},
textobjects = {
select = {
enable = true,
keymaps = {
['iF'] = {
python = '(function_definition) @function',
cpp = '(function_definition) @function',
c = '(function_definition) @function',
java = '(method_declaration) @function'
},
-- or you use the queries from supported languages with textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['aC'] = '@class.outer',
['iC'] = '@class.inner',
['ac'] = '@conditional.outer',
['ic'] = '@conditional.inner',
['ae'] = '@block.outer',
['ie'] = '@block.inner',
['al'] = '@loop.outer',
['il'] = '@loop.inner',
['is'] = '@statement.inner',
['as'] = '@statement.outer',
['ad'] = '@comment.outer',
['am'] = '@call.outer',
['im'] = '@call.inner'
}
}
}
}--,
--textobjects = {
-- select = {
-- enable = true,
-- keymaps = {
-- ['iF'] = {
-- python = '(function_definition) @function',
-- cpp = '(function_definition) @function',
-- c = '(function_definition) @function',
-- java = '(method_declaration) @function'
-- },
-- -- or you use the queries from supported languages with textobjects.scm
-- ['af'] = '@function.outer',
-- ['if'] = '@function.inner',
-- ['aC'] = '@class.outer',
-- ['iC'] = '@class.inner',
-- ['ac'] = '@conditional.outer',
-- ['ic'] = '@conditional.inner',
-- ['ae'] = '@block.outer',
-- ['ie'] = '@block.inner',
-- ['al'] = '@loop.outer',
-- ['il'] = '@loop.inner',
-- ['is'] = '@statement.inner',
-- ['as'] = '@statement.outer',
-- ['ad'] = '@comment.outer',
-- ['am'] = '@call.outer',
-- ['im'] = '@call.inner'
-- }
-- }
--}
}
vim.cmd [[set foldmethod=expr]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment