mason is a bit broken but LSP a lot better
This commit is contained in:
@@ -1,63 +1,90 @@
|
||||
local lspconfig = require('lspconfig');
|
||||
local lsp = require('lsp-zero')
|
||||
local cmp = require ('cmp')
|
||||
lsp.preset("recommended")
|
||||
|
||||
lsp.ensure_installed({
|
||||
'tsserver',
|
||||
'clangd',
|
||||
})
|
||||
|
||||
-- Fix Undefined global 'vim'
|
||||
lsp.configure('lua-language-server', {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'vim' }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
local cmp_mappings = lsp.defaults.cmp_mappings({
|
||||
["<Tab>"] = cmp.mapping.select_next_item(cmp_select),
|
||||
["<S-Tab>"] = cmp.mapping.select_prev_item(cmp_select),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
})
|
||||
|
||||
lsp.setup_nvim_cmp({
|
||||
mapping = cmp_mappings,
|
||||
})
|
||||
|
||||
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
suggest_lsp_servers = false,
|
||||
sign_icons = {
|
||||
error = '',
|
||||
warn = '',
|
||||
hint = '',
|
||||
info = ''
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = { 'clangd' }
|
||||
ensure_installed = { 'clangd'}
|
||||
})
|
||||
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', '<Leader>gD', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gT', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gI', '<Cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gR', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
-- Glance LSP
|
||||
vim.keymap.set('n', '<Leader>gd', '<CMD>Glance definitions<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gt', '<CMD>Glance type_definitions<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gi', '<CMD>Glance implementations<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gr', '<CMD>Glance references<CR>', opts)
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
local on_attatch = function(_, bufnr)
|
||||
lsp.on_attach(function(_, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
end
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', '<Leader>gD', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gT', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gI', '<Cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gR', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
-- Glance LSP
|
||||
vim.keymap.set('n', '<Leader>gd', '<CMD>Glance definitions<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gt', '<CMD>Glance type_definitions<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gi', '<CMD>Glance implementations<CR>', opts)
|
||||
vim.keymap.set('n', '<Leader>gr', '<CMD>Glance references<CR>', opts)
|
||||
end)
|
||||
|
||||
require('mason-lspconfig').setup_handlers({
|
||||
function(server)
|
||||
lspconfig[server].setup({
|
||||
on_attatch = on_attatch,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
lsp.setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true
|
||||
})
|
||||
|
||||
require('rust-tools').setup {
|
||||
server = {
|
||||
on_attatch = on_attatch,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
}
|
||||
|
||||
-- Specific LSP
|
||||
lspconfig.rust_analyzer.setup {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
disabled = {"unresolved-proc-macro"},
|
||||
enableExperimental = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- diagnostic symbols
|
||||
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
|
||||
-- completion symbols
|
||||
vim.lsp.protocol.CompletionItemKind = {
|
||||
" (Text) ",
|
||||
@@ -86,3 +113,4 @@ vim.lsp.protocol.CompletionItemKind = {
|
||||
" (Operator)",
|
||||
" (TypeParameter)"
|
||||
}
|
||||
|
||||
|
||||
233
common/.config/nvim/lua/plugin-config/feline.lua
Normal file
233
common/.config/nvim/lua/plugin-config/feline.lua
Normal file
@@ -0,0 +1,233 @@
|
||||
local line_ok, feline = pcall(require, "feline")
|
||||
if not line_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local one_monokai = {
|
||||
fg = "#abb2bf",
|
||||
bg = "#1e2024",
|
||||
green = "#98c379",
|
||||
yellow = "#e5c07b",
|
||||
purple = "#c678dd",
|
||||
orange = "#d19a66",
|
||||
peanut = "#f6d5a4",
|
||||
red = "#e06c75",
|
||||
aqua = "#61afef",
|
||||
darkblue = "#282c34",
|
||||
dark_red = "#f75f5f",
|
||||
}
|
||||
|
||||
local vi_mode_colors = {
|
||||
NORMAL = "green",
|
||||
OP = "green",
|
||||
INSERT = "yellow",
|
||||
VISUAL = "purple",
|
||||
LINES = "orange",
|
||||
BLOCK = "dark_red",
|
||||
REPLACE = "red",
|
||||
COMMAND = "aqua",
|
||||
}
|
||||
|
||||
local c = {
|
||||
vim_mode = {
|
||||
provider = {
|
||||
name = "vi_mode",
|
||||
opts = {
|
||||
show_mode_name = true,
|
||||
-- padding = "center", -- Uncomment for extra padding.
|
||||
},
|
||||
},
|
||||
hl = function()
|
||||
return {
|
||||
fg = require("feline.providers.vi_mode").get_mode_color(),
|
||||
bg = "darkblue",
|
||||
style = "bold",
|
||||
name = "NeovimModeHLColor",
|
||||
}
|
||||
end,
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
gitBranch = {
|
||||
provider = "git_branch",
|
||||
hl = {
|
||||
fg = "peanut",
|
||||
bg = "darkblue",
|
||||
style = "bold",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
gitDiffAdded = {
|
||||
provider = "git_diff_added",
|
||||
hl = {
|
||||
fg = "green",
|
||||
bg = "darkblue",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
gitDiffRemoved = {
|
||||
provider = "git_diff_removed",
|
||||
hl = {
|
||||
fg = "red",
|
||||
bg = "darkblue",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
gitDiffChanged = {
|
||||
provider = "git_diff_changed",
|
||||
hl = {
|
||||
fg = "fg",
|
||||
bg = "darkblue",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "right_filled",
|
||||
},
|
||||
separator = {
|
||||
provider = "",
|
||||
},
|
||||
fileinfo = {
|
||||
provider = {
|
||||
name = "file_info",
|
||||
opts = {
|
||||
type = "relative-short",
|
||||
},
|
||||
},
|
||||
hl = {
|
||||
style = "bold",
|
||||
},
|
||||
left_sep = " ",
|
||||
right_sep = " ",
|
||||
},
|
||||
diagnostic_errors = {
|
||||
provider = "diagnostic_errors",
|
||||
hl = {
|
||||
fg = "red",
|
||||
},
|
||||
},
|
||||
diagnostic_warnings = {
|
||||
provider = "diagnostic_warnings",
|
||||
hl = {
|
||||
fg = "yellow",
|
||||
},
|
||||
},
|
||||
diagnostic_hints = {
|
||||
provider = "diagnostic_hints",
|
||||
hl = {
|
||||
fg = "aqua",
|
||||
},
|
||||
},
|
||||
diagnostic_info = {
|
||||
provider = "diagnostic_info",
|
||||
},
|
||||
lsp_client_names = {
|
||||
provider = "lsp_client_names",
|
||||
hl = {
|
||||
fg = "purple",
|
||||
bg = "darkblue",
|
||||
style = "bold",
|
||||
},
|
||||
left_sep = "left_filled",
|
||||
right_sep = "block",
|
||||
},
|
||||
file_type = {
|
||||
provider = {
|
||||
name = "file_type",
|
||||
opts = {
|
||||
filetype_icon = true,
|
||||
case = "titlecase",
|
||||
},
|
||||
},
|
||||
hl = {
|
||||
fg = "red",
|
||||
bg = "darkblue",
|
||||
style = "bold",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
file_encoding = {
|
||||
provider = "file_encoding",
|
||||
hl = {
|
||||
fg = "orange",
|
||||
bg = "darkblue",
|
||||
style = "italic",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
position = {
|
||||
provider = "position",
|
||||
hl = {
|
||||
fg = "green",
|
||||
bg = "darkblue",
|
||||
style = "bold",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
line_percentage = {
|
||||
provider = "line_percentage",
|
||||
hl = {
|
||||
fg = "aqua",
|
||||
bg = "darkblue",
|
||||
style = "bold",
|
||||
},
|
||||
left_sep = "block",
|
||||
right_sep = "block",
|
||||
},
|
||||
scroll_bar = {
|
||||
provider = "scroll_bar",
|
||||
hl = {
|
||||
fg = "yellow",
|
||||
style = "bold",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local left = {
|
||||
c.vim_mode,
|
||||
c.gitBranch,
|
||||
c.gitDiffAdded,
|
||||
c.gitDiffRemoved,
|
||||
c.gitDiffChanged,
|
||||
c.separator,
|
||||
}
|
||||
|
||||
local middle = {
|
||||
c.fileinfo,
|
||||
c.diagnostic_errors,
|
||||
c.diagnostic_warnings,
|
||||
c.diagnostic_info,
|
||||
c.diagnostic_hints,
|
||||
}
|
||||
|
||||
local right = {
|
||||
c.lsp_client_names,
|
||||
c.file_type,
|
||||
c.file_encoding,
|
||||
c.position,
|
||||
c.line_percentage,
|
||||
c.scroll_bar,
|
||||
}
|
||||
|
||||
local components = {
|
||||
active = {
|
||||
left,
|
||||
middle,
|
||||
right,
|
||||
},
|
||||
inactive = {
|
||||
left,
|
||||
middle,
|
||||
right,
|
||||
},
|
||||
}
|
||||
|
||||
feline.setup({
|
||||
components = components,
|
||||
theme = one_monokai,
|
||||
vi_mode_colors = vi_mode_colors,
|
||||
})
|
||||
@@ -1,54 +0,0 @@
|
||||
local cmp = require 'cmp'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }),
|
||||
},
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "vsnip" },
|
||||
{ name = "path" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
@@ -151,43 +151,47 @@ local packer = require('packer').startup(function(use)
|
||||
|
||||
-- statusline
|
||||
use {
|
||||
'ojroques/nvim-hardline',
|
||||
'freddiehaddad/feline.nvim',
|
||||
config = function ()
|
||||
require('hardline').setup({})
|
||||
require('plugin-config/feline')
|
||||
end
|
||||
}
|
||||
|
||||
-- fancy notifications
|
||||
use 'rcarriga/nvim-notify'
|
||||
|
||||
-- FUNCTIONAL CODING STUFF
|
||||
|
||||
-- lsp config
|
||||
use {
|
||||
"williamboman/mason.nvim",
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v1.x',
|
||||
requires = {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
'simrat39/rust-tools.nvim',
|
||||
-- LSP Support
|
||||
{'neovim/nvim-lspconfig'},
|
||||
{'williamboman/mason.nvim'},
|
||||
{'williamboman/mason-lspconfig.nvim'},
|
||||
|
||||
-- Special LSP treatment
|
||||
{'simrat39/rust-tools.nvim'},
|
||||
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'},
|
||||
{'hrsh7th/cmp-nvim-lsp'},
|
||||
{'hrsh7th/cmp-nvim-lua'},
|
||||
{'hrsh7th/cmp-buffer'},
|
||||
{'hrsh7th/cmp-path'},
|
||||
{'hrsh7th/cmp-cmdline'},
|
||||
{'saadparwaiz1/cmp_luasnip'},
|
||||
|
||||
-- Snippets
|
||||
{'L3MON4D3/LuaSnip'},
|
||||
{'rafamadriz/friendly-snippets'},
|
||||
},
|
||||
config = function ()
|
||||
require('lsp-general')
|
||||
end
|
||||
}
|
||||
|
||||
-- for LSP autocompletion
|
||||
use {
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
},
|
||||
config = function ()
|
||||
require('plugin-config/nvim-cmp')
|
||||
end
|
||||
}
|
||||
|
||||
-- for lsp signature autocompletion
|
||||
use {
|
||||
'ray-x/lsp_signature.nvim',
|
||||
|
||||
Reference in New Issue
Block a user