fennel!
This commit is contained in:
parent
ed71640b56
commit
bf3b46b12a
137
.editorconfig
Normal file
137
.editorconfig
Normal file
|
@ -0,0 +1,137 @@
|
|||
[*.lua]
|
||||
# [basic]
|
||||
|
||||
# optional space/tab
|
||||
indent_style = space
|
||||
# if indent_style is space, this is valid
|
||||
indent_size = 4
|
||||
# if indent_style is tab, this is valid
|
||||
tab_width = 4
|
||||
# none/single/double
|
||||
quote_style = none
|
||||
|
||||
continuation_indent = 4
|
||||
|
||||
# this mean utf8 length , if this is 'unset' then the line width is no longer checked
|
||||
# this option decides when to chopdown the code
|
||||
max_line_length = 120
|
||||
|
||||
# optional crlf/lf/cr/auto, if it is 'auto', in windows it is crlf other platforms are lf
|
||||
# in neovim the value 'auto' is not a valid option, please use 'unset'
|
||||
end_of_line = unset
|
||||
|
||||
#optional keep/never/always/smart
|
||||
trailing_table_separator = keep
|
||||
|
||||
# keep/remove/remove_table_only/remove_string_only
|
||||
call_arg_parentheses = keep
|
||||
|
||||
detect_end_of_line = false
|
||||
|
||||
# this will check text end with new line
|
||||
insert_final_newline = true
|
||||
|
||||
# [space]
|
||||
space_around_table_field_list = true
|
||||
|
||||
space_before_attribute = true
|
||||
|
||||
space_before_function_open_parenthesis = false
|
||||
|
||||
space_before_function_call_open_parenthesis = false
|
||||
|
||||
space_before_closure_open_parenthesis = true
|
||||
|
||||
# optional always/only_string/only_table/none
|
||||
# or true/false
|
||||
space_before_function_call_single_arg = always
|
||||
|
||||
space_before_open_square_bracket = false
|
||||
|
||||
space_inside_function_call_parentheses = false
|
||||
|
||||
space_inside_function_param_list_parentheses = false
|
||||
|
||||
space_inside_square_brackets = false
|
||||
|
||||
# like t[#t+1] = 1
|
||||
space_around_table_append_operator = false
|
||||
|
||||
ignore_spaces_inside_function_call = false
|
||||
|
||||
space_before_inline_comment = 1
|
||||
|
||||
# [operator space]
|
||||
space_around_math_operator = true
|
||||
|
||||
space_after_comma = true
|
||||
|
||||
space_after_comma_in_for_statement = true
|
||||
|
||||
space_around_concat_operator = true
|
||||
|
||||
# [align]
|
||||
|
||||
align_call_args = false
|
||||
|
||||
align_function_params = true
|
||||
|
||||
align_continuous_assign_statement = true
|
||||
|
||||
align_continuous_rect_table_field = true
|
||||
|
||||
align_continuous_line_space = 2
|
||||
|
||||
align_if_branch = false
|
||||
|
||||
# option none / always / contain_curly/
|
||||
align_array_table = true
|
||||
|
||||
align_continuous_similar_call_args = false
|
||||
|
||||
align_continuous_inline_comment = true
|
||||
# option none / always / only_call_stmt
|
||||
align_chain_expr = none
|
||||
|
||||
# [indent]
|
||||
|
||||
never_indent_before_if_condition = false
|
||||
|
||||
never_indent_comment_on_if_branch = false
|
||||
|
||||
# [line space]
|
||||
|
||||
# The following configuration supports four expressions
|
||||
# keep
|
||||
# fixed(n)
|
||||
# min(n)
|
||||
# max(n)
|
||||
# for eg. min(2)
|
||||
|
||||
line_space_after_if_statement = keep
|
||||
|
||||
line_space_after_do_statement = keep
|
||||
|
||||
line_space_after_while_statement = keep
|
||||
|
||||
line_space_after_repeat_statement = keep
|
||||
|
||||
line_space_after_for_statement = keep
|
||||
|
||||
line_space_after_local_or_assign_statement = keep
|
||||
|
||||
line_space_after_function_statement = fixed(2)
|
||||
|
||||
line_space_after_expression_statement = keep
|
||||
|
||||
line_space_after_comment = keep
|
||||
|
||||
# [line break]
|
||||
break_all_list_when_line_exceed = false
|
||||
|
||||
auto_collapse_lines = false
|
||||
|
||||
# [preference]
|
||||
ignore_space_after_colon = false
|
||||
|
||||
remove_call_expression_list_finish_comma = false
|
3
fnl/core.fnl
Normal file
3
fnl/core.fnl
Normal file
|
@ -0,0 +1,3 @@
|
|||
(require :lazy-setup)
|
||||
(require :options)
|
||||
(require :custom-keys)
|
9
fnl/custom-keys.fnl
Normal file
9
fnl/custom-keys.fnl
Normal file
|
@ -0,0 +1,9 @@
|
|||
(let [nmap #(vim.keymap.set :n $1 $2 {:desc "$3"})]
|
||||
(nmap "<Tab>" ":bnext<CR>" "Next Buffer")
|
||||
(nmap "<S-Tab>" ":bprevious<CR>" "Previous Buffer")
|
||||
(nmap "<C-X>" ":write|bdelete<CR>" "Save and delete buffer")
|
||||
;; fuzzy finding
|
||||
(nmap "<C-P>" ":Telescope find_files<CR>" "Telescope find_files")
|
||||
(nmap "<C-F>" ":Telescope live_grep<CR>" "Telescope find_files")
|
||||
(nmap "<C-B>" ":Telescope buffers<CR>" "Telescope find_files")
|
||||
)
|
76
fnl/lazy-setup.fnl
Normal file
76
fnl/lazy-setup.fnl
Normal file
|
@ -0,0 +1,76 @@
|
|||
(local lazypath (.. (vim.fn.stdpath "data") "/lazy/lazy.nvim"))
|
||||
|
||||
(if (not (vim.loop.fs_stat lazypath))
|
||||
(vim.fn.system
|
||||
["git"
|
||||
"clone"
|
||||
"--filter=blob:none"
|
||||
"https://github.com/folke/lazy.nvim.git"
|
||||
"--branch=stable"
|
||||
lazypath]))
|
||||
|
||||
(let [lazy (require :lazy)]
|
||||
(lazy.setup
|
||||
["https://github.com/rktjmp/hotpot.nvim"
|
||||
{:url "https://github.com/nvim-telescope/telescope.nvim"
|
||||
:tag "0.1.2"
|
||||
:dependencies ["nvim-lua/plenary.nvim"]}
|
||||
{:url "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
|
||||
:build (.. "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release"
|
||||
" && cmake --build build --config Release"
|
||||
" && cmake --install build --prefix build" )}
|
||||
;; TODO LSP configurations...
|
||||
;; {:url "https://github.com/neovim/nvim-lspconfig"
|
||||
;; :dependencies
|
||||
;; ["https://github.com/williamboman/mason.nvim"
|
||||
;; "williamboman/mason-lspconfig.nvim"
|
||||
;; {:url "https://github.com/j-hui/fidget.nvim"
|
||||
;; :tag "legacy"
|
||||
;; :opts {}} ; NOTE: `opts = {}` is the same as calling `require("fidget").setup({})`
|
||||
;; "folke/neodev.nvim"]}
|
||||
]))
|
||||
|
||||
(let [telescope (require "telescope")]
|
||||
(pcall (telescope.load_extension :fzf)))
|
||||
|
||||
;; TODO fix LSP stuff...
|
||||
;; (let [neodev (require :neodev)]
|
||||
;; (neodev.setup))
|
||||
|
||||
;; TODO mason can't find the modules it installs...
|
||||
;; (let
|
||||
;; [mason (require :mason)
|
||||
;; mason-lspconfig (require :mason-lspconfig)
|
||||
;; servers
|
||||
;; {:lua_ls {
|
||||
;; :Lua {
|
||||
;; :workspace { :checkThirdParty false }
|
||||
;; :telemetry { :enable false }}}
|
||||
;; :fennel_language_server {}
|
||||
;; :bash_language_server {}
|
||||
;; :jq {}
|
||||
;; }
|
||||
;; on_attach (fn [_ bufnr]
|
||||
;; (let
|
||||
;; [nmap #(vim.keymap.set :n $1 $2 {:buffer bufnr :desc (.. "LSP: " $3)})
|
||||
;; telescope (require :telescope.builtin)
|
||||
;; ]
|
||||
;; (nmap :gd vim.lsp.buf.definition "[G]o to [D]efiniton")
|
||||
;; (nmap :gr telescope.lsp_references "[G]o to [R]eferences")
|
||||
;; (nmap :gI vim.lsp.buf.implementation "[G]o to [I]mplementation")
|
||||
;; (vim.api.nvim_buf_create_user_command bufnr "Format" #(vim.lsp.buf.format)
|
||||
;; "Format current buffer with LSP")))
|
||||
;; ]
|
||||
;; (mason.setup)
|
||||
;; (mason-lspconfig.setup)
|
||||
;; (mason-lspconfig.setup_handlers
|
||||
;; [(fn [server_name] (let
|
||||
;; [server (require server_name)
|
||||
;; settings (. servers server_name)
|
||||
;; filetypes (or settings.filetypes [])
|
||||
;; ]
|
||||
;; (server.setup {:capabilities (vim.lsp.protocol.make_client_capabilities)
|
||||
;; :on_attach on_attach
|
||||
;; :settings settings
|
||||
;; :filetypes filetypes})))
|
||||
;; ]))
|
3
fnl/options.fnl
Normal file
3
fnl/options.fnl
Normal file
|
@ -0,0 +1,3 @@
|
|||
(set vim.o.termguicolors true)
|
||||
(set vim.o.mouse :a)
|
||||
(set vim.o.clipboard :unnamedplus)
|
195
init.lua
195
init.lua
|
@ -1,190 +1,13 @@
|
|||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
local hotpot_path = vim.fn.stdpath('data') .. '/lazy/hotpot.nvim'
|
||||
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system {
|
||||
'git',
|
||||
'clone',
|
||||
'--filter=blob:none',
|
||||
'https://github.com/folke/lazy.nvim.git',
|
||||
'--branch=stable', -- latest stable release
|
||||
lazypath,
|
||||
}
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
vim.opt.rtp:prepend(hotpot_path)
|
||||
|
||||
require('lazy').setup({
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = {
|
||||
{ 'williamboman/mason.nvim', config = true },
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
{ 'j-hui/fidget.nvim', opts = {} },
|
||||
'folke/neodev.nvim',
|
||||
},
|
||||
},
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
dependencies = {
|
||||
'L3MON4D3/LuaSnip',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
},
|
||||
{ 'folke/which-key.nvim', opts = {} },
|
||||
{ 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } },
|
||||
{
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
build = 'make',
|
||||
cond = function()
|
||||
return vim.fn.executable 'make' == 1
|
||||
end,
|
||||
},
|
||||
}, {})
|
||||
|
||||
require('telescope').setup {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
['<C-u>'] = false,
|
||||
['<C-d>'] = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
pcall(require('telescope').load_extension, 'fzf')
|
||||
|
||||
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
||||
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
|
||||
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
|
||||
local on_attach = function(_, bufnr)
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = 'LSP: ' .. desc
|
||||
if vim.fn.empty(vim.fn.glob(hotpot_path)) > 0 then
|
||||
print("Could not find hotpot.nvim, cloning new copy to", hotpot_path)
|
||||
vim.fn.system({'git', 'clone',
|
||||
'https://github.com/rktjmp/hotpot.nvim', hotpot_path})
|
||||
vim.cmd("helptags " .. hotpot_path .. "/doc")
|
||||
end
|
||||
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||
|
||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
|
||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nmap('<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = 'Format current buffer with LSP' })
|
||||
end
|
||||
|
||||
local servers = {
|
||||
-- clangd = {},
|
||||
-- gopls = {},
|
||||
-- pyright = {},
|
||||
-- tsserver = {},
|
||||
-- rust_analyzer = {},
|
||||
lua_ls = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
diagnostics = {
|
||||
globals = {'minetest'},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
require('neodev').setup()
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
local mason_lspconfig = require 'mason-lspconfig'
|
||||
mason_lspconfig.setup {
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
}
|
||||
mason_lspconfig.setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
local cmp = require 'cmp'
|
||||
local luasnip = require 'luasnip'
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
luasnip.config.setup {}
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete {},
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
}
|
||||
require("hotpot")
|
||||
require("core")
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "51ebb4b6637290e1b8e0fb0d6f38b605d3c24940" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "0dd6114bea08276d9111d58c5dce5e256bbc8921" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "ebdd0499551765e6a7aba220cc8ae4e0cdb6be69" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "f0ce33f4794a2364eb08d09d09380e8b04ec5e6a" },
|
||||
"mason.nvim": { "branch": "main", "commit": "7d7efc738e08fc5bee822857db45cb6103f0b0c1" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "358f11c585fdccfcb5e8eae720c423fbed6d92de" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "fc0f694af1a742ada77e5b1c91ff405c746f4a26" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "8b578b76a522a5253d13d6cc9d84c2bbbe62dc17" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "499e0743cf5e8075cd32af68baa3946a1c76adf1" },
|
||||
"hotpot.nvim": { "branch": "master", "commit": "026eba9596b506ab6f807fd4aa93cd5f76255725" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "e86a4c84ff35240639643ffed56ee1c4d55f538e" },
|
||||
"mason.nvim": { "branch": "main", "commit": "fe9e34a9ab4d64321cdc3ecab4ea1809239bb73f" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "866b6b6e687a93ba98851a03a74bf6d9211b7299" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "b6091272422bb0fbd729f7f5d17a56d37499c54f" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" },
|
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "533c7fb1b3fb412a16e1c1c9cf6d2b1ac130f1b7" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "e271c28118998c93a14d189af3395812a1aa646c" }
|
||||
"telescope.nvim": { "branch": "master", "commit": "1228f3b15ca3d9b95dcb92efda6a3448871030bd" }
|
||||
}
|
Loading…
Reference in a new issue