migrate to mason-lspconfig
parent
a097dab167
commit
e65b2f308f
|
@ -1,3 +1,11 @@
|
||||||
|
-- What: Mono-file nvim configuration file
|
||||||
|
-- Why: Easy to see through everything without needing to navigate thru files
|
||||||
|
-- Features:
|
||||||
|
-- - LSP
|
||||||
|
-- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter)
|
||||||
|
-- - cmd: ":Format" to format
|
||||||
|
-- -
|
||||||
|
|
||||||
-- Basic settings of vim
|
-- Basic settings of vim
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
set number relativenumber
|
set number relativenumber
|
||||||
|
@ -13,13 +21,19 @@ set colorcolumn=80
|
||||||
set background=dark
|
set background=dark
|
||||||
]])
|
]])
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
|
vim.opt.cursorline = true
|
||||||
-- some plugins misbehave when we do swap files
|
-- some plugins misbehave when we do swap files
|
||||||
vim.opt.swapfile = false
|
vim.opt.swapfile = false
|
||||||
vim.opt.backup = false
|
vim.opt.backup = false
|
||||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||||
vim.opt.undofile = true
|
vim.opt.undofile = true
|
||||||
vim.opt.completeopt = 'menuone,noselect'
|
vim.opt.completeopt = 'menuone,noselect'
|
||||||
|
vim.opt.clipboard = "unnamedplus"
|
||||||
|
vim.opt.lazyredraw = true
|
||||||
|
|
||||||
|
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
|
vim.g.gruvbox_termcolors=16
|
||||||
|
|
||||||
-- basic keymaps
|
-- basic keymaps
|
||||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) -- since we're using space for leader
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) -- since we're using space for leader
|
||||||
|
@ -47,9 +61,10 @@ vim.call('plug#begin', '~/.config/nvim/plugged')
|
||||||
Plug('nvim-lua/plenary.nvim')
|
Plug('nvim-lua/plenary.nvim')
|
||||||
|
|
||||||
-- plugins
|
-- plugins
|
||||||
Plug('nvim-treesitter/nvim-treesitter') -- language parser engine
|
Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting
|
||||||
Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
|
Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
|
||||||
Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser
|
Plug('nvim-telescope/telescope.nvim', { tag = '0.1.0' }) -- file browser
|
||||||
|
Plug('nvim-telescope/telescope-fzf-native.nvim', {['do'] = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=release && cmake --build build --config Release && cmake --install build --prefix build'})
|
||||||
-- cmp: auto-complete/suggestions
|
-- cmp: auto-complete/suggestions
|
||||||
Plug('neovim/nvim-lspconfig') -- built-in LSP configurations
|
Plug('neovim/nvim-lspconfig') -- built-in LSP configurations
|
||||||
Plug('hrsh7th/cmp-nvim-lsp')
|
Plug('hrsh7th/cmp-nvim-lsp')
|
||||||
|
@ -88,9 +103,13 @@ end
|
||||||
-- Comment.nvim
|
-- Comment.nvim
|
||||||
require('Comment').setup()
|
require('Comment').setup()
|
||||||
-- lukas-reineke/indent-blankline.nvim
|
-- lukas-reineke/indent-blankline.nvim
|
||||||
require('indent_blankline').setup {
|
vim.opt.list = true
|
||||||
char = '┊',
|
vim.opt.listchars:append "space:⋅"
|
||||||
show_trailing_blankline_indent = false,
|
vim.opt.listchars:append "eol:↴"
|
||||||
|
|
||||||
|
require("indent_blankline").setup {
|
||||||
|
show_end_of_line = true,
|
||||||
|
space_char_blankline = " ",
|
||||||
}
|
}
|
||||||
-- telescope
|
-- telescope
|
||||||
require('telescope').setup {
|
require('telescope').setup {
|
||||||
|
@ -99,7 +118,15 @@ require('telescope').setup {
|
||||||
i = {
|
i = {
|
||||||
['<C-u>'] = false,
|
['<C-u>'] = false,
|
||||||
['<C-d>'] = false,
|
['<C-d>'] = false,
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extensions = {
|
||||||
|
fzf = {
|
||||||
|
fuzzy = true, -- allow fuzzy matches
|
||||||
|
override_generic_sorter = true,
|
||||||
|
override_file_sorter = true,
|
||||||
|
case_mode = 'smart_case'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,19 +145,20 @@ remap('n', '<leader>fh', function()
|
||||||
require('telescope.builtin').help_tags()
|
require('telescope.builtin').help_tags()
|
||||||
end, { desc = '[F]ind [H]elp' })
|
end, { desc = '[F]ind [H]elp' })
|
||||||
remap('n', '<leader>fd', function()
|
remap('n', '<leader>fd', function()
|
||||||
require('telescope.builtin').live_grep()
|
require('telescope.builtin').diagnostics()
|
||||||
end, { desc = '[F]ind [D]iagnostics' })
|
end, { desc = '[F]ind [D]iagnostics' })
|
||||||
-- treesitter
|
-- treesitter
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python' },
|
ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' },
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymap = {
|
keymaps = {
|
||||||
init_selection = '<c-space>',
|
init_selection = '<c-space>',
|
||||||
node_incremental = '<c-space>',
|
node_incremental = '<c-space>',
|
||||||
node_decremental = '<c-backspace>'
|
node_decremental = '<c-backspace>',
|
||||||
|
scope_incremental = '<c-S>'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
textobjects = {
|
textobjects = {
|
||||||
|
@ -195,7 +223,7 @@ end
|
||||||
-- nvim-cmp supports additional completion capabilities
|
-- nvim-cmp supports additional completion capabilities
|
||||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
-- default language servers
|
-- default language servers
|
||||||
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua' }
|
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', "prisma-language-server" }
|
||||||
require("mason").setup({
|
require("mason").setup({
|
||||||
ui = {
|
ui = {
|
||||||
icons = {
|
icons = {
|
||||||
|
@ -207,15 +235,17 @@ require("mason").setup({
|
||||||
})
|
})
|
||||||
require('mason-lspconfig').setup({
|
require('mason-lspconfig').setup({
|
||||||
ensure_installed = servers,
|
ensure_installed = servers,
|
||||||
-- automatic_installation = true
|
automatic_installation = true
|
||||||
})
|
})
|
||||||
for _, lsp in ipairs(servers) do
|
require('mason-lspconfig').setup_handlers({
|
||||||
require('lspconfig')[lsp].setup {
|
-- default handler
|
||||||
|
function(server_name)
|
||||||
|
require('lspconfig')[server_name].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
end
|
end,
|
||||||
-- config overwrites
|
["sumneko_lua"] = function()
|
||||||
require('lspconfig').sumneko_lua.setup {
|
require('lspconfig').sumneko_lua.setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
@ -235,6 +265,9 @@ require('lspconfig').sumneko_lua.setup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
-- nvim-cmp
|
-- nvim-cmp
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
@ -291,9 +324,5 @@ require('gitsigns').setup {
|
||||||
require('lualine').setup {
|
require('lualine').setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = 'onedark',
|
|
||||||
component_separators = '|',
|
|
||||||
section_separators = '',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue