neovim lsp
This commit is contained in:
parent
9951fed49b
commit
1c7f17ea30
11 changed files with 295 additions and 37 deletions
|
@ -49,6 +49,7 @@
|
|||
"nasm" ;; devlopment packages
|
||||
"rust" ;; packages usefull for coding and devlopment
|
||||
"gcc-toolchain"
|
||||
"clang-toolchain"
|
||||
"racket"
|
||||
"python"
|
||||
"node"
|
||||
|
@ -117,7 +118,7 @@
|
|||
(zprofile (list (local-file "zsh/zprofile")))))
|
||||
|
||||
(service home-xdg-configuration-files-service-type
|
||||
`(("nvim/init.vim" ,(local-file "nvim/init.vim"))
|
||||
`(("nvim" ,(local-file "nvim" #:recursive? #t))
|
||||
("sway" ,(local-file "sway" #:recursive? #t))
|
||||
("waybar" ,(local-file "waybar" #:recursive? #t))
|
||||
("alacritty" ,(local-file "alacritty" #:recursive? #t))
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
lua
|
||||
lua52Packages.dkjson
|
||||
lua52Packages.luaposix
|
||||
lua-language-server
|
||||
];
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
|
|
7
home-config/nvim/init.lua
Normal file
7
home-config/nvim/init.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
require('plugin')
|
||||
require('theme')
|
||||
require('vimopt')
|
||||
require('tree')
|
||||
require('keybinds')
|
||||
require('treesitter')
|
||||
require('lsp')
|
|
@ -1,36 +0,0 @@
|
|||
call plug#begin()
|
||||
|
||||
Plug 'itchyny/lightline.vim'
|
||||
|
||||
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
|
||||
|
||||
call plug#end()
|
||||
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
|
||||
colorscheme tokyonight-moon
|
||||
let g:lightline = {'colorscheme': 'tokyonight'}
|
||||
|
||||
set mouse=v
|
||||
set mouse=a
|
||||
set clipboard=unnamedplus
|
||||
set autoindent
|
||||
set hlsearch
|
||||
set tabstop=4
|
||||
set shiftwidth=0
|
||||
set expandtab
|
||||
set number
|
||||
set cc=80
|
||||
set encoding=utf-8
|
||||
set nofoldenable
|
||||
set laststatus=2
|
||||
set noshowmode
|
||||
set modeline
|
||||
set mouse=a
|
||||
set ttyfast
|
||||
set colorcolumn=0
|
||||
|
||||
hi Normal guibg=NONE ctermbg=NONE
|
||||
hi LineNr term=bold cterm=bold ctermfg=2 guifg=White guibg=NONE
|
||||
|
18
home-config/nvim/lua/keybinds.lua
Normal file
18
home-config/nvim/lua/keybinds.lua
Normal file
|
@ -0,0 +1,18 @@
|
|||
local opts = { noremap = true, silent = true }
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
keymap('', '<leader>', '<Nop>', opts)
|
||||
keymap('n', '<leader>e', ':NvimTreeToggle %<CR>', opts)
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
keymap('n', '<leader>ff', builtin.find_files, {})
|
||||
keymap('n', '<leader>fg', builtin.live_grep, {})
|
||||
keymap('n', '<leader>fb', builtin.buffers, {})
|
||||
keymap('n', '<leader>fh', builtin.help_tags, {})
|
||||
keymap('n', '<leader>u', vim.cmd.UndotreeToggle)
|
||||
keymap('n', '<leader>gs', vim.cmd.Git)
|
73
home-config/nvim/lua/lsp.lua
Normal file
73
home-config/nvim/lua/lsp.lua
Normal file
|
@ -0,0 +1,73 @@
|
|||
local lsp = require('lsp-zero')
|
||||
|
||||
lsp.preset('recommended')
|
||||
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'tsserver',
|
||||
'eslint',
|
||||
'rust_analyzer',
|
||||
'clangd',
|
||||
'html',
|
||||
'cssls',
|
||||
'pyright',
|
||||
'vimls',
|
||||
'yamlls',
|
||||
'jdtls',
|
||||
'bashls',
|
||||
'lua_ls'
|
||||
},
|
||||
handlers = {
|
||||
lsp.default_setup,
|
||||
},
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
|
||||
local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
||||
local cmp_mappings = cmp.mapping.preset.insert({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
})
|
||||
|
||||
cmp_mappings['<Tab>'] = nil
|
||||
cmp_mappings['<S-Tab>'] = nil
|
||||
|
||||
cmp.setup({
|
||||
mapping = cmp_mappings
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
suggest_lsp_servers = false,
|
||||
sign_icons = {
|
||||
error = 'E',
|
||||
warn = 'W',
|
||||
hint = 'H',
|
||||
info = 'I'
|
||||
}
|
||||
})
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
local opts = {buffer = bufnr, remap = false}
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
keymap("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
keymap("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
keymap("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
keymap("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
||||
keymap("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
keymap("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
keymap("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
keymap("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
||||
keymap("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
keymap("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end)
|
||||
|
||||
lsp.setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true
|
||||
})
|
28
home-config/nvim/lua/plugin.lua
Normal file
28
home-config/nvim/lua/plugin.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local Plug = vim.fn['plug#']
|
||||
|
||||
vim.call('plug#begin')
|
||||
|
||||
Plug('nvim-tree/nvim-web-devicons')
|
||||
Plug('nvim-tree/nvim-tree.lua')
|
||||
Plug('nvim-lualine/lualine.nvim')
|
||||
Plug('ryanoasis/vim-devicons')
|
||||
Plug('SirVer/ultisnips')
|
||||
Plug('honza/vim-snippets')
|
||||
Plug('preservim/nerdcommenter')
|
||||
Plug('mhinz/vim-startify')
|
||||
Plug('neoclide/coc.nvim', {branch = 'release'})
|
||||
Plug('nvim-telescope/telescope.nvim', {tag = '0.1.3' })
|
||||
Plug('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'})
|
||||
Plug('nvim-lua/plenary.nvim')
|
||||
Plug('mbbill/undotree')
|
||||
Plug('catppuccin/nvim', {as = 'catppuccin'})
|
||||
Plug('tpope/vim-fugitive')
|
||||
Plug('neovim/nvim-lspconfig')
|
||||
Plug('hrsh7th/nvim-cmp')
|
||||
Plug('hrsh7th/cmp-nvim-lsp')
|
||||
Plug('L3MON4D3/LuaSnip')
|
||||
Plug('williamboman/mason.nvim')
|
||||
Plug('williamboman/mason-lspconfig.nvim')
|
||||
Plug('VonHeikemen/lsp-zero.nvim', {branch = 'v3.x'})
|
||||
|
||||
vim.call('plug#end')
|
22
home-config/nvim/lua/theme.lua
Normal file
22
home-config/nvim/lua/theme.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
local options = {
|
||||
termguicolors = true
|
||||
}
|
||||
|
||||
local colorscheme = "catppuccin"
|
||||
local ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
||||
vim.o.background = "dark" -- or "light" for light mode
|
||||
if not ok then
|
||||
vim.notify("colorscheme " .. colorscheme .. " not found!")
|
||||
return
|
||||
end
|
||||
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
theme = colorscheme,
|
||||
icons_enabled = true,
|
||||
globalstatus = true,
|
||||
},
|
||||
}
|
||||
|
||||
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
101
home-config/nvim/lua/tree.lua
Normal file
101
home-config/nvim/lua/tree.lua
Normal file
|
@ -0,0 +1,101 @@
|
|||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
local function on_attach(bufnr)
|
||||
local api = require("nvim-tree.api")
|
||||
|
||||
local function opts(desc)
|
||||
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
||||
end
|
||||
|
||||
local function edit_or_open()
|
||||
local node = api.tree.get_node_under_cursor()
|
||||
|
||||
if node.nodes ~= nil then
|
||||
-- expand or collapse folder
|
||||
api.node.open.edit()
|
||||
else
|
||||
-- open file
|
||||
api.node.open.edit()
|
||||
-- Close the tree if file was opened
|
||||
api.tree.close()
|
||||
end
|
||||
end
|
||||
|
||||
api.config.mappings.default_on_attach(bufnr)
|
||||
vim.keymap.set("n", "<CR>", edit_or_open, opts("Open"))
|
||||
end
|
||||
|
||||
require("nvim-tree").setup({
|
||||
sort_by = "case_sensitive",
|
||||
view = {
|
||||
width = 30,
|
||||
},
|
||||
renderer = {
|
||||
group_empty = true,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = true,
|
||||
global = false,
|
||||
restrict_above_cwd = false,
|
||||
},
|
||||
expand_all = {
|
||||
max_folder_discovery = 300,
|
||||
exclude = {},
|
||||
},
|
||||
file_popup = {
|
||||
open_win_config = {
|
||||
col = 1,
|
||||
row = 1,
|
||||
relative = "cursor",
|
||||
border = "shadow",
|
||||
style = "minimal",
|
||||
},
|
||||
},
|
||||
open_file = {
|
||||
window_picker = {
|
||||
enable = false,
|
||||
picker = "default",
|
||||
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
|
||||
exclude = {
|
||||
filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||
buftype = { "nofile", "terminal", "help" },
|
||||
},
|
||||
}
|
||||
},
|
||||
remove_file = {
|
||||
close_window = true,
|
||||
},
|
||||
|
||||
},
|
||||
tab = {
|
||||
sync = {
|
||||
open = false,
|
||||
close = false,
|
||||
ignore = {},
|
||||
},
|
||||
},
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = false,
|
||||
show_on_dirs = true,
|
||||
show_on_open_dirs = true,
|
||||
timeout = 200,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
git_clean = false,
|
||||
no_buffer = false,
|
||||
custom = { "node_modules", "\\.cache" },
|
||||
exclude = {},
|
||||
},
|
||||
update_cwd = true,
|
||||
respect_buf_cwd = true,
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_cwd = true
|
||||
},
|
||||
on_attach = on_attach
|
||||
})
|
30
home-config/nvim/lua/treesitter.lua
Normal file
30
home-config/nvim/lua/treesitter.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
local lsps = {
|
||||
"c",
|
||||
"lua",
|
||||
"rust",
|
||||
"typescript",
|
||||
"javascript",
|
||||
"python",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"query"
|
||||
};
|
||||
|
||||
require('nvim-treesitter.configs').setup {
|
||||
ensure_installed = lsps,
|
||||
sync_install = false,
|
||||
auto_install = true,
|
||||
ignore_install = { "javascript" },
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = { "c", "rust" },
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
13
home-config/nvim/lua/vimopt.lua
Normal file
13
home-config/nvim/lua/vimopt.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
local set = vim.opt
|
||||
set.tabstop = 4
|
||||
set.softtabstop = 4
|
||||
set.shiftwidth = 4
|
||||
set.mouse = "a"
|
||||
set.clipboard = "unnamedplus"
|
||||
set.hlsearch = true
|
||||
set.autoindent = true
|
||||
set.ttyfast = true
|
||||
set.cc = '80'
|
||||
set.number = true
|
||||
set.relativenumber = true
|
||||
set.rnu = true
|
Loading…
Reference in a new issue