Commit a920a0b6 authored by Tim van Deurzen's avatar Tim van Deurzen

Many local changes after some autocomplete issues.

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